Last active
March 9, 2022 00:53
-
-
Save mnh48/19e237ab21c6e1885f251c7b0b2b2784 to your computer and use it in GitHub Desktop.
This is a script to update translation source strings from mods' lua source code. The script is for Minetest mods that supports intllib and had strings needing translation passed via intllib's functions declared correctly. The script was taken from homedecor_modpack and tweaked it so it is usable in common mods' locale folder.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# To create a new translation: | |
# msginit --locale=ll_CC -o locale/ll_CC.po -i locale/template.pot | |
cd "$(dirname "${BASH_SOURCE[0]}")/.."; | |
# Extract translatable strings. | |
xgettext --from-code=UTF-8 \ | |
--language=Lua \ | |
--sort-by-file \ | |
--keyword=S \ | |
--keyword=NS:1,2 \ | |
--keyword=N_ \ | |
--add-comments='Translators:' \ | |
--add-location=file \ | |
-o locale/template.pot \ | |
$(find . -name '*.lua') | |
# Update translations. | |
find locale -name '*.po' | while read -r file; do | |
echo $file | |
msgmerge --update $file locale/template.pot; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The script was taken from minetest-mods/homedecor_modpack/homedecor_i18n/tools/updatepo.sh and tweaked it so it is usable in common mods' locale folder. See homedecor_modpack's license for reusing this code.