From 17f602da1a2289240ee8838f164d087793dfa890 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 27 Apr 2021 20:52:59 +0000 Subject: [PATCH] Create a CI job to check strings.po files The new "translation" job that will be available only when strings.po files are modified. It will use the msgcmp tool to check that the translation files use the correct reference strings. A new part is also added in the contribution guidelines to help future translators to start up. See merge request StCyr/plugin.video.peertube!21 for more information --- .gitlab-ci.yml | 21 +++++++++++++++++++++ contributing.md | 17 ++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c503a04..1a79990 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -45,6 +45,27 @@ quality: expire_in: 1 week when: always +# Translation job: check that all the string.po files use the same strings as +# the reference file +translation: + stage: validation + # Do not get any artifacts from previous jobs + dependencies: [] + rules: + # Run this job only on merge requests containing changes in strings.po + # files and only as "manual" + - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' + changes: + - resources/language/*/strings.po + when: manual + before_script: + - *apt_get_update + - apt-get install --yes gettext > /dev/null + # We cannot use a simple "find ... -exec msgcmp {} strings.po" because it + # would always return 0 as exit code + script: + - files=$(find . -name strings.po -not -path './resources/language/resource.language.en_gb/*') && for file in $files; do echo -e "\n\033[94mChecking translation file $file\033[0m"; msgcmp $file ./resources/language/resource.language.en_gb/strings.po; done + # Pre-release job: will be available in all the merge requests with release # branches in order to verify the release can be actually created. The # verification is done by running the release script in dry run mode. diff --git a/contributing.md b/contributing.md index 0a65f2e..4a4e8f1 100644 --- a/contributing.md +++ b/contributing.md @@ -59,7 +59,7 @@ It contains 2 classes: received from `addon.py` * PeertubeDownloader: downloads torrent in an independent thread -This module must be as short as possible (15 effective lines of code maximum) +This module should be as short as possible (15 effective lines of code maximum) to comply with Kodi add-on development best practices (checked by the [Kodi add-on checker](https://github.com/xbmc/addon-check)). @@ -141,3 +141,18 @@ These steps should be followed only by maintainers. 4. A new pipeline with the job `create-release` will be created: run the job manually since it should be `blocked` (maintainers only) 5. The new release will be available on the releases page. + +## Translation + +To translate the add-on you may: +* edit one of the `strings.po` file existing in the subfolders of + `resources/language` +* create a new `strings.po` for your language + +A CI job called `translation` is available in each merge request which contains +changes in strings.po files. It checks that the reference strings in the +translation files are the same as in the reference file +([resources/language/resource.language.en_gb/strings.po](./resources/language/resource.language.en_gb/strings.po)). + +More information on the translation system used by Kodi and its add-ons is +available [here](https://kodi.wiki/view/Language_support).