Added translation base
This commit is contained in:
29
scripts/i18n_compile.sh
Executable file
29
scripts/i18n_compile.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
DOMAIN="dynalab"
|
||||
LOCALES_DIR="locales"
|
||||
|
||||
found_po=false
|
||||
|
||||
for po_file in "$LOCALES_DIR"/*/LC_MESSAGES/"$DOMAIN.po"; do
|
||||
if [[ ! -f "$po_file" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
found_po=true
|
||||
mo_file="${po_file%.po}.mo"
|
||||
|
||||
echo "Checking $po_file"
|
||||
msgfmt --check "$po_file"
|
||||
|
||||
echo "Compiling $po_file -> $mo_file"
|
||||
msgfmt "$po_file" -o "$mo_file"
|
||||
done
|
||||
|
||||
if [[ "$found_po" == false ]]; then
|
||||
echo "No .po files found in $LOCALES_DIR/*/LC_MESSAGES/$DOMAIN.po"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Compiled all locales"
|
||||
19
scripts/i18n_extract.sh
Executable file
19
scripts/i18n_extract.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
DOMAIN="dynalab"
|
||||
SOURCE_DIR="src/dynalab"
|
||||
LOCALES_DIR="locales"
|
||||
POT_FILE="$LOCALES_DIR/$DOMAIN.pot"
|
||||
|
||||
mkdir -p "$LOCALES_DIR"
|
||||
|
||||
xgettext \
|
||||
--language=Python \
|
||||
--keyword=_ \
|
||||
--keyword=gettext_ \
|
||||
--from-code=UTF-8 \
|
||||
--output="$POT_FILE" \
|
||||
$(find "$SOURCE_DIR" -name "*.py" | sort)
|
||||
|
||||
echo "Generated $POT_FILE"
|
||||
Reference in New Issue
Block a user