mirror of
https://github.com/element-hq/element-web.git
synced 2024-12-12 02:15:28 +03:00
71a0ced8a8
...in the Translations dev guide
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 'matrix-react-sdk/lib/languageHandler';
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/strings
(respect which repository you are on).
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. - If using translated strings as constants, translated strings can't be in constants loaded at class-load time since the translations won't be loaded.
- If a string is presented in the UI with punctuation like a full stop, include this in the translation strings, since punctuation varies between languages too.