Skip to content

Commit

Permalink
Rewrite translation process (#745)
Browse files Browse the repository at this point in the history
* Replace some russian translations

* Delete extra translation files + merge Russian and French into single files + add German

* Add logic for using new translations + clean up .pro files

* Add readme + sample for translating

* Modify CI
  • Loading branch information
kleo-53 committed Feb 3, 2024
1 parent f4e39e2 commit 8ea0ea0
Show file tree
Hide file tree
Showing 24 changed files with 1,185 additions and 587 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
version: ${{matrix.qt-version}}
arch: win32_mingw${{matrix.mingw-short-version}}
modules: 'qtscript'
archives: 'qtbase qtsvg qtserialport qtmultimedia qtwinextras qtimageformats i686'
archives: 'qtbase qtsvg qtserialport qtmultimedia qtwinextras qtimageformats i686 qttools'
tools: 'tools_mingw,qt.tools.win32_mingw${{matrix.mingw-short-version}}0'
extra: '--external 7z'

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
make -j 4
```

# Add translations
[Details here](https://github.com/kleo-53/trikRuntime/blob/master/translations/ADDING_TRANSLATIONS.en.md)

# Out-of-source-tree build (split-build) is supported

===========
Expand Down
1 change: 0 additions & 1 deletion global.pri
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ QMAKE_CXXFLAGS += -Werror=cast-qual -Werror=write-strings -Werror=redundant-decl

gcc4:QMAKE_CXXFLAGS += -Wno-error=missing-field-initializers


# Simple function that checks if given argument is a file or directory.
# Returns false if argument 1 is a file or does not exist.
defineTest(isDir) {
Expand Down
52 changes: 52 additions & 0 deletions translations/ADDING_TRANSLATIONS.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Adding Translation to the TrikRuntime Project

1. Fork the repository:
* Go to the [project repository page](https://github.com/trikset/trikRuntime/tree/master) on GitHub.
* Click the "Fork" button in the top right corner. This will create a copy of the repository on your account.

2. Clone your forked repository to your computer:
```shell
git clone https://github.com/your-username/trikRuntime.git
cd trikRuntime
```

3. Create a new branch for your work:
```shell
git checkout -b add-translation-<language_code>
```

4. Edit the translation (more details below).

5. Run the project (**Qt Linguist** is recommended) and ensure that the new language is displayed correctly.

6. Commit changes and push them to GitHub:
```shell
git add .
git commit -m "Add translation for <language>"
git push origin add-translation-<language_code>
```

7. Create a Pull Request:
* Go to your forked repository on GitHub.
* Click the "Compare & pull request" button next to your branch.
* Fill in the description of the changes and create the Pull Request. Other contributors may review and request changes if necessary. Once the changes are reviewed and approved, they can be merged into the main repository.


## Adding Translation for a New Language
1. Add a translation file for the desired language to the `translations` folder in the format `trikRuntime_<language_code>.ts`.
2. Copy the structure from the `trikRuntime_sample.ts` file. Replace `language="en"` with the code of your language (check it [here](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) --- Table, Set 1).
3. Modify the project code to use translations from the new file. Open the `translations/translations.pro` file in **Qt Creator** and add a line after `TRANSLATIONS +=` with the name of your file:
```shell
$$PWD/trikRuntime_<language_code>.ts \
```
4. Open the `trikRuntime.pro` file and add a line after `TRANSLATIONS +=` with the name of your file:
```shell
$$PWD/translations/trikRuntime_<language_code>.ts \
```
5. Run lupdate in **Qt Creator**: go to *Tools -> External -> Linguist -> Update Translations (lupdate)*. Now your created file contains the source strings for translation.
6. Add translations for the language using Qt Linguist. Open your file through **Qt Linguist** and add translations to the strings.
7. Rebuild the project in **Qt Creator** (*Build -> Build Project trikRuntime*) to generate new translation files.

## Editing Existing Translation Files
1. It is recommended to use **Qt Linguist**. Open your file through it and add translations to the strings.
2. Rebuild the project in **Qt Creator** (*Build -> Build Project trikRuntime*) to generate new translation files.
1 change: 0 additions & 1 deletion translations/fr/locale.ini

This file was deleted.

44 changes: 0 additions & 44 deletions translations/fr/trikKernel_fr.ts

This file was deleted.

43 changes: 0 additions & 43 deletions translations/fr/trikRun_fr.ts

This file was deleted.

33 changes: 0 additions & 33 deletions translations/fr/trikScriptRunner_fr.ts

This file was deleted.

1 change: 0 additions & 1 deletion translations/ru/locale.ini

This file was deleted.

46 changes: 0 additions & 46 deletions translations/ru/trikKernel_ru.ts

This file was deleted.

48 changes: 0 additions & 48 deletions translations/ru/trikRun_ru.ts

This file was deleted.

33 changes: 0 additions & 33 deletions translations/ru/trikScriptRunner_ru.ts

This file was deleted.

23 changes: 10 additions & 13 deletions translations/translations.pro
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.

TEMPLATE = subdirs

TEMPLATE = lib
include(../global.pri)
TRANSLATIONS_DIR=$$system_quote($$DESTDIR/translations/)
win32:TRANSLATIONS_DIR=$$system(cygpath -u $$TRANSLATIONS_DIR)
system(bash -c $$system_quote(find $$shell_quote($$PWD) -name '*.ts' -print0 | xargs -0 $$[QT_HOST_BINS/get]/lrelease -removeidentical))
system(bash -c $$system_quote(rsync -vrdmR --remove-source-files --include='*/' --include='*.qm' --exclude='*' ./ $$TRANSLATIONS_DIR))
system(bash -c $$system_quote(rsync -vrdmR --include='*/' --include='*.ini' --exclude='*' ./ $$TRANSLATIONS_DIR))
TRANSLATIONS_DIR=$$DESTDIR/translations/
LRELEASE_DIR=$$DESTDIR/translations/

OTHER_FILES += \
$$PWD/ru/locale.ini \
$$PWD/fr/locale.ini \
TRANSLATIONS += \
$$PWD/trikRuntime_ru.ts \
$$PWD/trikRuntime_fr.ts \
$$PWD/trikRuntime_de.ts \

OTHER_FILES += \
$$PWD/ru/*.ts \
$$PWD/fr/*.ts \
CONFIG += lrelease

OTHER_FILES += \
$$PWD/*.ts \
installAdditionalSharedFiles($$DESTDIR/translations)
Loading

0 comments on commit 8ea0ea0

Please sign in to comment.