Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load dinamically locale_data #37

Open
raurodse opened this issue Mar 3, 2015 · 4 comments
Open

Load dinamically locale_data #37

raurodse opened this issue Mar 3, 2015 · 4 comments

Comments

@raurodse
Copy link

raurodse commented Mar 3, 2015

is it possible change locale_data dinamically when JED object is already created?

@mandx
Copy link

mandx commented Dec 7, 2016

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'));

@Suhoy95
Copy link

Suhoy95 commented May 17, 2017

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.

@SlexAxton
Copy link
Member

SlexAxton commented May 17, 2017 via email

@Suhoy95
Copy link

Suhoy95 commented May 17, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants