globalizejs / globalize

A JavaScript library for internationalization and localization that leverages the official Unicode CLDR JSON data
https://globalizejs.com
MIT License
4.8k stars 603 forks source link

Globalize.loadTranslations #749

Closed DamirUtje closed 7 years ago

DamirUtje commented 7 years ago

Hello,

i'm using the current release version 1.2.3 and would like to use the functionality you described here: https://github.com/globalizejs/globalize/blob/6d3a5a57c56fd0afb93e20340905a435d1650341/doc/api/message/load-translation.md#example

background: i need to inherit translations to have a fallback culture for the case that a browser culture is not defined / initialized in my loadMessages method. For example: Globalize.loadMessages({ root: { hello: "Hi!" }, de: { hello: "Moin!" } });

So i expect to this :

`Globalize("de-DE").formatMessage( "hello" ); // > "Moin"

Globalize( "fr" ).formatMessage( "amen" ); // > "Hi!" (fallback) ` How can i realize this?

rxaviers commented 7 years ago

Could you re-post your question in StackOverflow please (instructions)? I will reply there. Thanks

DamirUtje commented 7 years ago

Here we go : https://stackoverflow.com/questions/44908831/globalize-version-1-2-3-root-fallback-culture

diligiant commented 7 years ago

This might help @rxaviers answer your Q on SO: I am confused as in your question you give the answer (github link). Is this not working ?

DamirUtje commented 7 years ago

The Globalize lib Version 1.2.3 does not have the Globalize.loadTranslations and Globalize.formatTranslations methods. Maybe it will be implemented feature releases?!

rxaviers commented 7 years ago

https://stackoverflow.com/a/44948925/798133