Jed
Jed copied to clipboard
Load dinamically locale_data
is it possible change locale_data dinamically when JED object is already created?
Feels like a hack, but this works:
Load the translations, in Jed's format, using po2json
or whatever
const translations = po2json.parse(poFileContent, { format: 'jed1.x' });
const i18n = new Jed({}); // Empty instance
Later...
Object.assign(i18n.options, translations);
then...
console.log(i18n.gettext('My string'));
Hello, what about to make this functionality in Jed method?
In my cases i need to load additional translations dynamically and i don't want write this hack.
I would not consider this a hack. You're just adding more keys to the translation object. On Wed, May 17, 2017 at 1:54 AM Илья Сухоплюев [email protected] wrote:
Hello, what about to make this functionality in Jed method?
In my cases i need to load additional translations dynamically and i don't want write this hack.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/messageformat/Jed/issues/37#issuecomment-302002562, or mute the thread https://github.com/notifications/unsubscribe-auth/AAF5KnLspBb8Ij6qZgqx6Y_p7_mB6fvMks5r6pm7gaJpZM4Don1G .
Ok. Maybe it should be in documentation that new Jed (options) and i18n.options have identical structure. And we can change this data safely if i keep structure's integrity (or something similar, it may require more conditions to keep i18n-object in work state).
However, i have realized that creation of new i18n-object is more dumb and clear way in cases where this trick may be appropriate.