From 6967e0a537a55ea9e53d81c060bebda48b5b7973 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Mon, 6 Jul 2020 15:29:05 -0400 Subject: [PATCH] feat: add readme on how to use the translation script --- docs/README.md | 3 +++ scripts/translationScripts/README.md | 32 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 scripts/translationScripts/README.md diff --git a/docs/README.md b/docs/README.md index e4559f1170..4362d98334 100644 --- a/docs/README.md +++ b/docs/README.md @@ -26,3 +26,6 @@ ### API * [QML Nim-Status-Client API reference](https://github.com/status-im/nim-status-client/blob/master/docs/qml_api.md) + +### Translations +* [How to translate and use automatic scripts](https://github.com/status-im/nim-status-client/blob/master/scripts/translationScripts/README.md) diff --git a/scripts/translationScripts/README.md b/scripts/translationScripts/README.md new file mode 100644 index 0000000000..4adb19353c --- /dev/null +++ b/scripts/translationScripts/README.md @@ -0,0 +1,32 @@ +# Translation scripts + +These scripts are used to translate the app automatically by reusing the existing translation found in the Status-React repo: https://github.com/status-im/status-react/tree/develop/translations + +## TLDR + +1. Copy the translation files from https://github.com/status-im/status-react/tree/develop/translations to `/nim-status-client/scripts/translationScripts/status-react-translations` +2. Run `node qstrConverter.js` in the `translationScripts/` directory +3. Run `lupdate` in the `ui/` directory + +:tada: You're files are converted to use `qsTrId` and the translation files are updated. + +## Changing strings to IDs + +One major step is to change the literal strings we use in the code base to the IDs that are used in the translation JSON files. + +For example, in our QML files, we would use `qsTr("Public chat")`, but in Status-React, that string in only represented as `public-chat`. + +Thankfully, QML supports using string IDs instead of literral strings. The trick is to use `qsTrId` instead of `qsTr` and then use a comment to show the context/original string. + +The script to do the change from `qsTr` to `qsTrId` is `qstrConverter.js`. + +First, copy the translation files from https://github.com/status-im/status-react/tree/develop/translations to `/nim-status-client/scripts/translationScripts/status-react-translations`. Those are gitignored to show that we do not maintain those ourselves. + +Then, run `node qstrConverter.js` in the `translationScripts/` directory. + +## Updating translation files + +Updating the QML translation files is then very easy, as it comes with QT directly. It will scan all files in the projects (those listed in the `SOURCE` section of the `.pro` file) and then add or modify them in the XML-like `.ts` files. + +Just run `lupdate` in the `ui/` directory. +