stefalda / react-localization

Simple module to localize the React interface using the same syntax used in the ReactNativeLocalization module.
MIT License
372 stars 57 forks source link

Translation for english countries like Canada or US. #109

Open max-lynn opened 4 years ago

max-lynn commented 4 years ago

I'm trying to add translations for prices for canada and the US using the abbreviations en-CA and en-US but this is causing an error because of the dash.

Is there something else I need to do to have translation for these regions?

stefalda commented 4 years ago

Try to wrap the language code in quotes:

{
  "en-CA":{
                  hello: "Hello"
          }
}

And you can access it with strings["en-CA"].

MarkJDocumentaal commented 10 months ago

Ideally there would be an implementation like this:

{ en: { hello: "Hello", goodbye: "Goodbye", } "en-CA":{ hello: "Howdy" } }

Where if I set my language to en-US or en-GB, it would return 'Hello', but if I set it to en-CA it returns 'Howdy' for hello, but if I ask for goodbye, on not finding that entry in en-CA, it defaults to looking in en. That way only different translations have to be inputted for regional languages