Closed olivierbeaulieu closed 10 years ago
Cool, thanks so much for this -- there have been a few other requests for this functionality. I would support a PR that does this, however I think for simplicity and performance reasons, rather than trying to split the key and look up a nested phrase at translation time (in t()
), it would be better to just normalize a phrase object into a string key at extend()
time. Then the t()
method can be unchanged. Make sense?
That makes a lot of sense, i'll update the code and give you an update once that's done!
I might beat you to it! I'm about to open a PR with this functionality. Just couldn't help it -- too fun :)
Check it out: https://github.com/airbnb/polyglot.js/pull/12
Terrific. Thanks a bunch!
We are switching our whole app to Polyglot because it's awesome, so let me know if you need anything, I'll be happy to help!
Cool, merged! Give it a try. Closing for https://github.com/airbnb/polyglot.js/pull/12.
I migrated to polyglot from another library that allowed nested JSONs as such:
This wasn't possible with Polyglot so I added it. Simply add allowNestedJSON: true when instantiating Polyglot, and it'll work.
I know there's a similar PR opened, but I think it's cleaner to have everything pass through the t() method.
Let me know what you think.