You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for providing the react-intl-universal library. I have used it easily without any issue.
but currently language local data is not in a single file but on multiple JSON files in the local folder. so I have to load all the JSON files from the local folder and then display the data. I am considering only one language currently.
Thanks in advance.
The text was updated successfully, but these errors were encountered:
Hi @cwtuan, thanks for the fix. Having language local data in multiple files is a great, and a must-have feature for any non-trivial application.
The issue I'm having is with the standard Object.assign function which is used in the load function implementation: it overrides existing defined locales.
Example:
ComponentOne has locales defined in the same folder, in the file localesOne.json:
{
"en-US": {
"hello": "hello from component one"
}
}
ComponentTwo has locales defined in the same folder, in the file localesTwo.json:
{
"en-US": {
"hello": "hello from component two"
}
}
load function is used in each of the respective components:
The issue occurs when the load function is invoked for the second time, it overrides the entire en-US locale which was already loaded. This means that once the locales for componentTwo are loaded, locales for componentOne are non existent any more (and vice versa).
The solution for this could be using deep merge, thus preserving the old values within the object being extended.
This way the load method could be leveraged in each of the smart components, and managing .json files throughout the application woud be nice and easy.
Is this something that could potentially be implemented?
Hi there,
Thanks for providing the react-intl-universal library. I have used it easily without any issue.
but currently language local data is not in a single file but on multiple JSON files in the local folder. so I have to load all the JSON files from the local folder and then display the data. I am considering only one language currently.
Thanks in advance.
The text was updated successfully, but these errors were encountered: