Closed cyphix333 closed 7 years ago
Put equivalent translations under the same root language tag. You would make an entry for "en", and en-us/gb will automatically get translations from "en"
Can you give an example? Are you saying you can't make en-US.json
and en-GB.json
files and have to make a en.json
file with all the locales in it?
However, I'm still unsure if this means you can leave out data that doesn't need translating as it's either the default language or is the same in en-GB
as it is in the default language.
As stated by eligrey, you could solve this requirement by structuring your localized messages as follows:
{ "en":{ "my message": "my message" }, "en-US": { "color": "color" }, "en-GB": { "color": "colour" } }
when a property is not found for an specific locale variant ("en-US" for example), it will search its base locale ("en" in this case).
Just starting to use this library and wondering for like the default language or similar ones do you need to provide the translation if one is not needed?
For example, say your translation is
l("my message")
then you would normally have to do something like this:Whereas, if not already an acceptable way to do it, something like this would save a lot of repeated data and code bloat:
So basically if it didn't find the translation then the text would remain the same; in this instance we would be using
en-US
as our default (writing) language and hence no translations are needed anden-GB
is very similar so the file should only need to contain the translations that actually need to be translated.Is this an acceptable way of doing it or does all translations have to be put in the files whether they need translating or not?