mirror of
https://github.com/itdoginfo/podkop.git
synced 2026-01-31 14:50:58 +03:00
feat: Add scripts for generating and updating translation templates
This commit is contained in:
29
luci-app-podkop/msgmerge.sh
Normal file
29
luci-app-podkop/msgmerge.sh
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
PODIR="po"
|
||||||
|
POTFILE="$PODIR/templates/podkop.pot"
|
||||||
|
|
||||||
|
if [ $# -ne 1 ]; then
|
||||||
|
echo "Usage: $0 <language_code> (e.g., ru, de, fr)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
LANG="$1"
|
||||||
|
POFILE="$PODIR/$LANG/podkop.po"
|
||||||
|
|
||||||
|
if [ ! -f "$POTFILE" ]; then
|
||||||
|
echo "Template $POTFILE not found. Run xgettext first."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$POFILE" ]; then
|
||||||
|
echo "Updating $POFILE"
|
||||||
|
msgmerge --update "$POFILE" "$POTFILE"
|
||||||
|
else
|
||||||
|
echo "Creating new $POFILE using msginit"
|
||||||
|
mkdir -p "$PODIR/$LANG"
|
||||||
|
msginit --no-translator --locale="$LANG" --input="$POTFILE" --output-file="$POFILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Translation file for $LANG updated."
|
||||||
22
luci-app-podkop/xgettext.sh
Normal file
22
luci-app-podkop/xgettext.sh
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
SRC_DIR="htdocs/luci-static/resources/view/podkop"
|
||||||
|
OUT_POT="po/templates/podkop.pot"
|
||||||
|
ENCODING="UTF-8"
|
||||||
|
|
||||||
|
mapfile -t FILES < <(find "$SRC_DIR" -type f -name "*.js")
|
||||||
|
if [ ${#FILES[@]} -eq 0 ]; then
|
||||||
|
echo "No JS files found in $SRC_DIR"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p "$(dirname "$OUT_POT")"
|
||||||
|
|
||||||
|
echo "Generating POT template from JS files in $SRC_DIR"
|
||||||
|
xgettext --language=JavaScript \
|
||||||
|
--keyword=_ \
|
||||||
|
--from-code="$ENCODING" \
|
||||||
|
--output="$OUT_POT" \
|
||||||
|
"${FILES[@]}"
|
||||||
|
|
||||||
|
echo "POT template generated: $OUT_POT"
|
||||||
Reference in New Issue
Block a user