Closed bent0b0x closed 5 years ago
For almost all cases, you'll want to use the TranslatedText component
https://github.com/Paratii-Video/paratii-portal/blob/dev/src/scripts/components/translations/TranslatedText.js
You pass it a message prop, which is just a string key leading to the path in the json language file
if your translation needs to include variables, you can pass as many as you need in the options prop
<TranslatedText
message="search.results.resultsFor"
options={{ term: searchTerm }}
/>
It is up to you to make sure the the key exists in the in the english json file. If it doesn't, no error will be thrown but only the literal key will render (e.g. search.results.resultsFor)
Declaring a translation is fairly easy. It is normally just a string in a json object. But if you need a variable, here is an example:
"resultsFor": "Results for: %{term}"
where %{term} is a placeholder for a variable that is passed in at runtime
Related to #676.
We should update the readme (or create a new doc) outlining the translation system and, most importantly, how it should be used from the perspective of translators and devs.