mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-05 06:29:23 +02:00
See #161: initial setup to collect/compile messages with vue-gettext
This commit is contained in:
parent
a1b8555c17
commit
a0a75c9919
7 changed files with 381 additions and 10 deletions
3
front/scripts/i18n-compile.sh
Executable file
3
front/scripts/i18n-compile.sh
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash -eux
|
||||
locales=$(tail -n +2 src/locales.js | sed -e 's/export default //' | jq '.locales[].code' | xargs echo)
|
||||
find locales -name '*.po' | xargs $(yarn bin gettext-extract)/gettext-compile --output src/translations.json
|
25
front/scripts/i18n-extract.sh
Executable file
25
front/scripts/i18n-extract.sh
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash -eux
|
||||
locales=$(tail -n +2 src/locales.js | sed -e 's/export default //' | jq '.locales[].code' | xargs echo)
|
||||
locales_dir="locales"
|
||||
sources=$(find src -name '*.vue' -o -name '*.html' 2> /dev/null)
|
||||
js_sources=$(find src -name '*.vue' -o -name '*.js')
|
||||
touch $locales_dir/app.pot
|
||||
|
||||
# Create a main .pot template, then generate .po files for each available language.
|
||||
# Extract gettext strings from templates files and create a POT dictionary template.
|
||||
$(yarn bin gettext-extract)/gettext-extract --attribute v-translate --quiet --output $locales_dir/app.pot $sources
|
||||
xgettext --language=JavaScript --keyword=npgettext:1c,2,3 \
|
||||
--from-code=utf-8 --join-existing --no-wrap \
|
||||
--package-name=$(node -e "console.log(require('./package.json').name);") \
|
||||
--package-version=$(node -e "console.log(require('./package.json').version);") \
|
||||
--output $locales_dir/app.pot $js_sources
|
||||
|
||||
# Generate .po files for each available language.
|
||||
echo $locales
|
||||
for lang in $locales; do \
|
||||
po_file=$locales_dir/$lang/LC_MESSAGES/app.po; \
|
||||
echo "msgmerge --update $po_file "; \
|
||||
mkdir -p $(dirname $po_file); \
|
||||
[ -f $po_file ] && msgmerge --lang=$lang --update $po_file $locales_dir/app.pot || msginit --no-translator --locale=$lang --input=$locales_dir/app.pot --output-file=$po_file; \
|
||||
msgattrib --no-wrap --no-obsolete -o $po_file $po_file; \
|
||||
done;
|
Loading…
Add table
Add a link
Reference in a new issue