dev-docs: Add documentation how to debug/test translations locally

This commit is contained in:
balooii balooii
2025-09-06 11:59:33 +02:00
parent d8b4df4e1f
commit 88274b0ea8
2 changed files with 67 additions and 1 deletions

View File

@@ -299,6 +299,30 @@ exit
## Translating Kdenlive ## Translating Kdenlive
TODO Kdenlive uses KDE's internationalization (i18n) system for translations. For submitting or updating translations, please use the official KDE translation platform at [l10n.kde.org](https://l10n.kde.org/).
The local translation workflow described below is for debugging purposes only. It can be useful when debugging translation issues or verifying translations work correctly in your local build in case you added or updated strings in the codebase.
**Note**: All text that should be translatable must use one of KDE's i18n functions like `i18nc()`, `i18np()`, etc. For more information about these functions, see the [KI18n documentation](https://api.kde.org/frameworks/ki18n/html/prg_guide.html).
#### Prerequisites
Make sure you have the required tools installed (extractrc, gettext):
```bash
# Arch Linux
sudo pacman -S gettext kde-dev-scripts
# Debian/Ubuntu
sudo apt install gettext kde-dev-utils
```
#### Translation Workflow
1. **Extract strings (creates `.pot` file with all translatable strings from the source code)**: `bash extract_i18n_strings.sh`
2. **Update existing translation (updates `.po` file)**: `msgmerge --update po/fi/kdenlive.po po/kdenlive.pot`
3. **Edit translations**: Modify the `msgstr` entries in the `.po` file
4. **Compile translations (creates .mo file)**: `msgfmt -o po/fi/kdenlive.mo po/fi/kdenlive.po`
5. **Test**: Run Kdenlive (Switch to the target language via Settings | Configure Language)
[fuzzer-blog]: https://kdenlive.org/en/2019/03/inside-kdenlive-how-to-fuzz-a-complex-gui-application/ [fuzzer-blog]: https://kdenlive.org/en/2019/03/inside-kdenlive-how-to-fuzz-a-complex-gui-application/

42
extract_i18n_strings.sh Executable file
View File

@@ -0,0 +1,42 @@
#!/bin/sh
# SPDX-FileCopyrightText: None
# SPDX-License-Identifier: CC0-1.0
# Extract i18n strings from Kdenlive source code for local debugging/testing purposes
# This script properly handles i18nc, i18np, i18ncp, and other KDE i18n functions used in the codebase
# See dev-docs/build.md for the complete translation workflow documentation
# Code for kde_xgettext() from https://invent.kde.org/sysadmin/l10n-scripty/-/blob/master/extract-messages.sh
kde_xgettext() {
xgettext --copyright-holder="This file is copyright:" \
--package-name=kdenlive \
--msgid-bugs-address=https://bugs.kde.org \
--from-code=UTF-8 \
-C --kde \
-ci18n \
-ki18n:1 -ki18nc:1c,2 -ki18np:1,2 -ki18ncp:1c,2,3 \
-ki18nd:2 -ki18ndc:2c,3 -ki18ndp:2,3 -ki18ndcp:2c,3,4 \
-kki18n:1 -kki18nc:1c,2 -kki18np:1,2 -kki18ncp:1c,2,3 \
-kki18nd:2 -kki18ndc:2c,3 -kki18ndp:2,3 -kki18ndcp:2c,3,4 \
-kxi18n:1 -kxi18nc:1c,2 -kxi18np:1,2 -kxi18ncp:1c,2,3 \
-kxi18nd:2 -kxi18ndc:2c,3 -kxi18ndp:2,3 -kxi18ndcp:2c,3,4 \
-kkxi18n:1 -kkxi18nc:1c,2 -kkxi18np:1,2 -kxi18ncp:1c,2,3 \
-kkxi18nd:2 -kkxi18ndc:2c,3 -kxi18ndp:2,3 -kxi18ndcp:2c,3,4 \
-kkli18n:1 -kkli18nc:1c,2 -kki18np:1,2 -kki18ncp:1c,2,3 \
-kklxi18n:1 -kklxi18nc:1c,2 -kklxi18np:1,2 -kklxi18ncp:1c,2,3 \
-kI18N_NOOP:1 -kI18NC_NOOP:1c,2 \
-kI18N_NOOP2:1c,2 -kI18N_NOOP2_NOSTRIP:1c,2 \
-ktr2i18n:1 -ktr2xi18n:1 \
"$@"
}
# Export the function so it's available to child scripts
export -f kde_xgettext
export XGETTEXT="kde_xgettext"
export EXTRACTRC=extractrc
export podir=po
# Reuse the existing Messages.sh script to extract the strings into a .pot file
bash Messages.sh