Skip to content

Commit 6bfc90b

Browse files
authored
Merge pull request element-hq#6528 from aidalgol/string-translation-change-doc
Add instructions for changing translated strings
2 parents 4e6c2fd + 95b09cd commit 6bfc90b

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎docs/translating-dev.md‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
## Requirements
44

55
- A working [Development Setup](../../#setting-up-a-dev-environment)
6+
- Including up-to-date versions of matrix-react-sdk and matrix-js-sdk
7+
- Node 8 or later
68
- Be able to understand English
79
- Be able to understand the language you want to translate riot-web into
810

@@ -30,9 +32,15 @@ function getColorName(hex) {
3032

3133
1. Check if the import ``import { _t } from 'matrix-react-sdk/lib/languageHandler';`` is present. If not add it to the other import statements. Also import `_td` if needed.
3234
1. Add ``_t()`` to your string. (Don't forget curly braces when you assign an expression to JSX attributes in the render method). If the string is introduced at a point before the translation system has not yet been initialized, use `_td()` instead, and call `_t()` at the appropriate time.
33-
1. Run `npm run i18n` to update ``src/i18n/strings/en_EN.json`` (if it fails because it can't find the script, your dev environment predates the script, so reinstall/link react-sdk with `npm link ../matrix-react-sdk`). If it segfaults, you may be on Node 6, so try a newer version of node.
35+
1. Run `npm run i18n` to update ``src/i18n/strings/en_EN.json``
3436
1. If you added a string with a plural, you can add other English plural variants to ``src/i18n/strings/en_EN.json`` (remeber to edit the one in the same project as the source file containing your new translation).
3537

38+
## Editing existing strings
39+
40+
1. Edit every occurrence of the string inside `_t()` and `_td()` in the JSX files.
41+
1. Run `npm run i18n` to update `src/i18n/strings/en_EN.json`. (Be sure to run this in the same project as the JSX files you just edited.)
42+
1. Run `npm run prunei18n` to remove the old string from `src/i18n/strings/*.json`.
43+
3644
## Adding variables inside a string.
3745

3846
1. Extend your ``_t()`` call. Instead of ``_t(STRING)`` use ``_t(STRING, {})``

0 commit comments

Comments
 (0)