Skip to content

Instantly share code, notes, and snippets.

@mnh48
Last active March 9, 2022 00:53
Show Gist options
  • Save mnh48/19e237ab21c6e1885f251c7b0b2b2784 to your computer and use it in GitHub Desktop.
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.
#! /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
@mnh48
Copy link
Author

mnh48 commented Feb 5, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment