forked from matrix/element-web
1.6 KiB
1.6 KiB
How to translate riot-web (Dev Guide)
Requirements
- A working Development Setup
- Be able to understand English
- Be able to understand the language you want to translate riot-web into
Adding new strings
- Check if the import
import _t from 'counterpart-riot'
is present. If not add it to the other import statements. - Add
_t()
to your string. (Don't forget curly braces when you assign an expression to JSX attributes in the render method) - Add the String to the
en_EN.json
file insrc/i18n
or if you are working in matrix-react-sdk you can find the json file insrc/i18n/strings
Adding variables inside a string.
- Extend your
_t()
call. Instead of_t(STRING)
use_t(STRING, {})
- Decide how to name it. Please think about if the person who has to translate it can understand what it does.
- Add it to the array in
_t
for example_t(STRING, {variable: this.variable})
- Add the variable inside the string. The syntax for variables is
%(variable)s
. Please note the s at the end. The name of the variable has to match the previous used name.
Things to know/Style Guides
- Do not use it inside
getDefaultProps
at the point wheregetDefaultProps
is initialized the translations aren't loaded yet and it causes missing translations. - Do use
Array.push()
instead of directly defining it inside the array. Arrays are not able to access_t()
at runtime. - Do not include full stops, Emoji or similiar miscellaneous Things to the strings. They are not required to be translated.