mirror of
https://github.com/lucaspalomodevelop/indico-plugins.git
synced 2026-03-12 23:27:22 +00:00
Add script that handles i18n operations
init, extract and update can be done for all plugins at once
This commit is contained in:
parent
d1eb171957
commit
547e8a7023
7
babel-js.cfg
Normal file
7
babel-js.cfg
Normal file
@ -0,0 +1,7 @@
|
||||
[javascript: static/**.js]
|
||||
encoding = utf-8
|
||||
domain = messages-js
|
||||
|
||||
[javascript: templates/**.html]
|
||||
encoding = utf-8
|
||||
domain = messages-js
|
||||
10
babel.cfg
Normal file
10
babel.cfg
Normal file
@ -0,0 +1,10 @@
|
||||
[python: **.py]
|
||||
encoding = utf-8
|
||||
|
||||
[jinja2: templates/**.txt]
|
||||
encoding = utf-8
|
||||
extensions = jinja2.ext.autoescape, jinja2.ext.with_
|
||||
|
||||
[jinja2: templates/**.html]
|
||||
encoding = utf-8
|
||||
extensions = jinja2.ext.autoescape, jinja2.ext.with_
|
||||
39
manage-i18n.sh
Executable file
39
manage-i18n.sh
Executable file
@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
|
||||
USAGE="$0 [init <locale>|extract|update <locale>|compile <locale>]"
|
||||
|
||||
if [[ "$1" == '-h' || "$1" == '--help' ]]; then
|
||||
echo "$USAGE"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ACTION="$1"
|
||||
LOCALE="$2"
|
||||
|
||||
function require_locale {
|
||||
if [[ -z "$LOCALE" ]]; then
|
||||
echo "$USAGE"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ ! "init extract update compile" =~ $ACTION ]]; then
|
||||
echo "$USAGE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for plugin in $(find . -name setup.py -exec sh -c 'basename $(dirname $0)' {} \;); do
|
||||
pushd "${plugin}" >/dev/null
|
||||
if [[ "$ACTION" == "init" ]]; then
|
||||
require_locale
|
||||
pybabel init -l "$LOCALE" -i "./indico_${plugin}/translations/messages.pot" -d "./indico_${plugin}/translations/"
|
||||
elif [[ "$ACTION" == "extract" ]]; then
|
||||
TRANSLATIONS_DIR="./indico_${plugin}/translations"
|
||||
pybabel extract -o "${TRANSLATIONS_DIR}/messages.pot" "indico_${plugin}" -F ../babel.cfg
|
||||
pybabel extract -o "${TRANSLATIONS_DIR}/messages-js.pot" "indico_${plugin}" -k 'gettext' -k 'ngettext' -k '$T' -F ../babel-js.cfg
|
||||
elif [[ "$ACTION" == "update" ]]; then
|
||||
require_locale
|
||||
pybabel update -i "./indico_${plugin}/translations/messages.pot" -l "$LOCALE" -d "./indico_${plugin}/translations"
|
||||
fi
|
||||
popd >/dev/null
|
||||
done
|
||||
0
run-tests.sh
Normal file → Executable file
0
run-tests.sh
Normal file → Executable file
Loading…
x
Reference in New Issue
Block a user