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

locale in .getCompiledData() should default to fallback locale #9

Closed
elmigranto opened this issue Dec 28, 2012 · 3 comments
Closed

Comments

@elmigranto
Copy link
Contributor

locale in .getCompiledData() should default to fallback locale, but following adds store['undefined']:

var BabelFish = require('babelfish');
var i18n = new BabelFish('ru');

i18n.addPhrase('ru', 'i', 'я');

console.dir(i18n.getCompiledData());
console.dir(i18n._storage);

Outputs:

{ ru: 
   { i: 
      { type: 'string',
        locale: 'ru',
        translation: 'я' } },
  undefined: 
   { i: 
      { type: 'string',
        locale: 'ru',
        translation: 'я' } } }
@puzrin
Copy link
Member

puzrin commented Dec 31, 2012

Please, write a more essential test, what will be broken in real life.

@puzrin
Copy link
Member

puzrin commented Dec 31, 2012

getCompiledData() MUST have locale param (the first one).

@puzrin puzrin closed this as completed Dec 31, 2012
@elmigranto
Copy link
Contributor Author

Please, write a more essential test, what will be broken in real life.

Something test-like in first-message already. I'd like to help in other way, but currently have no time to dig into internals, sorry. Maybe later, doesn't seem so critical anyway.

Nothing will break, just feels odd. As far as I can see, such call results in compiling phrases for fallbackLocale and writing result to _storage['undefined'] returned by getLocaleStorage(this, undefined). Now we have two disctinct objects with same data (_storage[fallbackLocale] and storage['undefined'], latter just lives there and probably never going to be used / GC'ed), memory wasted.

getCompiledData() MUST have locale param (the first one).

Throw then? (It's done in addPhrase and other places, so I guess there is no policy against exceptions.)

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

2 participants