Closed MadsAppvice closed 3 years ago
this package is for server side only. And global should be used in single user cli for example.
Great, it works flawlessly as a translation engine for a chrome extension though:-) And this has been my only issue so far, which was pretty simple to work around.
interesting :) so there is shim for fs
and such?
Well I could imagine that could be done, but no. I simply used webpack to load language files and add them statically. The size of the project makes the size of the language files negligible.
But it would be doable to shim fs and make fetches instead with a little setup.
Cheers and thanks for a nice module:-)
If the registration is set to global when using i18n on a webpage, "this" in the i18nTranslate function will be set to the window. If there is an element with the id="locale", the browser makes an easy reference to the element in the windows object, thus window.locale becomes the element.
This makes the getLocaleFromObject choose this element as the locale, which is obviously not the intention.
The workaround is to overwrite the reference to the element:
window.locale = undefined;
When initialising i18n.A solution would be to add a check on the locale to be a string, and if there is a static catalog to make sure it is a part of that.