The Website is translated on Codeberg Translate.
(!) Please don't edit localized Markdown files (.lang.md) manually.
The translation process has three steps:
English Markdown to .PO files. A special po4a tool parses English source files (i.e. without .lang. suffix) to extract all localizable strings into .po files in po/ directory. Markdown files are tokenized by the tool to extract individual paragraphs, list items and other elements into separate translatable strings. The source English files are never changed by the tool. English Markdown files can be freely edited directly in the repo without any issues. Every re-run of ./i18n.sh script will re-scan English sources to update .pot and .po files in ./po directory. The tool does the best to perform fuzzy matching over previous translation strings whenever it is possible. Updated .pot and .po and files should be committed together with changed English Markdown files.
Translation of .PO files. Weblate automatically pulls recent data from .pot and .po files from the main of the repo and makes new strings available for translation. Translation teams works in their pace to localize new strings via Weblate web-interface. Weblate sends Pull Requests with updated PO files once per day if any changes available. Weblate never touches Markdown files. It is also possible edit .po files directly in the repo - Weblate will updated when changes are pushed into main.
.PO to localized Markdown files. The second function of po4a tool is to incorporate new translations from .po files into localized (.lang.md) files. Localized Markdown files are always regenerated from the source English file by performing simple replacement of English strings with localized strings from .po files. Formatting of the original English source files is always fully preserved and replicated to all other locales as a result of this simple process. All strings without localization in .po files are kept untouched in English.
Install po4a tool. Version 0.68 is tested and supported. All other versions are tested.
Debian/Ubuntu:
apt-get install po4a
Fedora/RedHat:
dnf install po4a
macOS:
brew install po4a
- Add/edit source English Markdown files in the repo.
- Refresh
.potand.pofiles when English is changed by running./tools/i18n.sh. - Push both updated content and refreshed
.pot/.pofiles in the single PR to GitHub. - Translation teams will be notified via Weblate when your PR is merged.
- All new strings will be in English until localized (see the next step).
- Use Weblate web interface to update translations.
- It is also OK to update
.pofiles directly in repo. - Don't touch localized
.lang.mdfiles.
- Checkout
weblate-i18nbranch when it is updated by Weblate. - Run
./tools/i18n.shtool to regenerate.lang.mdfiles from updated.pofiles. - Update
.config.tomlif a new language is added. - Translate
menu.titleYAML Front Matters key manually, this is a well-known limitation. - Run
zola serverto check changes locally. - Create or update PR with incorporated
.lang.mdchanges. - Get your PR merged into
main. - Never force-push to
mainbranch - it will lock Weblate.
- Add the language code to
.po4a.cfg - run
./tools/i18n.shto update / generate translation and content files - translate the
languagekey in the languages.pofile to make sure the correct language name is displayed in the language selector instead of "English" - run
./tools/i18n.shagain to propagate the translation change - deploy website locally to test changes
- New web-site pages and languages should be added to
.po4a.cfgconfiguration file manually.
Merge conflicts between the Weblate and the actual repo can happen for many reasons (e.g. if you accidentally force-pushed to the main branch). When conflicts happen this will lock the Weblate. If this happens: Do not panic, this is recoverable without losing translations, but requires some effort.
Here is a step-by-step guide:
- Make sure the translations on Weblate are actually locked, to make sure that no more changes are done on Weblate while the conflict is being fixed. You will need to have the right Weblate permissions to do this.
- Commit all changes from the Weblate internal database to the Weblate-internal Git repository, the steps in the UI are: Manage → Repository Maintenance → Commit (button). This ensures that all existing translations are in the Weblate-internal Git repo. (this also requires the right Weblate permissions)
- Now you can add the weblate-internal Git repo as remote for your local repo:
git remote add weblate https://translate.codeberg.org/git/comaps/website/. This step only needs to be the first time you have to resolve a conflict - Make sure that your local main branch is at the latest remote state, e.g. by running
git checkout main; git pull - Now you can fetch the current state of the Weblate remote:
git fetch weblate - To be able to rebase the Codeberg
maininto the Weblate one, you need to have an editable branch. You can create it usinggit checkout -b resolve_translate weblate/main. This creates a branch calledresolve_translateoff the Weblate remote, and also switches you to this newly created branch. - You can now run
git rebase main, to rebase the branch and resolve any conflicts that are between the two. (Note: Make sure to run this command from yourresolve_translatebranch) - Once you have resolved the conflicts, you can push the
resolve_translatebranch to Codeberg:git push - Make a PR for merging your conflict-resolution-branch into
mainon Codeberg, and get it reviewed as usual - Once the PR is merged into
mainon Codeberg and the merge conflict is gone, you can now unlock the translations on Weblate again. - Optionally if necessary: If the conflict hasn't resolved through the steps, you can optionally reset the Weblate from the admin backend for the
websitecomponent, this forces the current state from the Codeberg git repo into Weblate
Using these steps all existing translations can still be kept and rebased into the repo, without losing work. The important bit is that you need to ensure that all translations are in the Weblate-internal git repository before you rebase, so that they get into the actual Codeberg repo.