Skip to content

Commit

Permalink
build: co-opt i18n-init.sh to kick start an empty app folder
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Donald <[email protected]>
  • Loading branch information
systemcrash committed Oct 21, 2024
1 parent 24bbea6 commit dc44c7a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
6 changes: 3 additions & 3 deletions build/i18n-add-language.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

LANGS=$@
if [ "$#" -eq 0 ]; then
echo $0 "adds i18n catalogue(s) in po/ folders (luci-app-*, luci-mod-*, etc) for each LUCI_LANG.* in luci.mk"
echo $(basename "$0") "adds i18n catalogue(s) in po/ folders (luci-app-*, luci-mod-*, etc) for each LUCI_LANG.* in luci.mk"
echo "Hint: run in the root of the luci repo or in your luci-app-* folder."

# get existing language codes from luci.mk
Expand All @@ -14,8 +14,8 @@ else
case "$LANG" in
[a-z][a-z]|[a-z][a-z][_-][A-Za-z][A-Za-z]*) : ;;
*)
echo $0 "adds i18n catalogues in each folder (luci-app-*, luci-mod-*, etc)."
echo "Usage: $0 <ISO_CODE> [<ISO_CODE> <ISO_CODE> ...]" >&2
echo $(basename "$0") "adds i18n catalogues in each folder (luci-app-*, luci-mod-*, etc)."
echo "Usage: $(basename "$0") <ISO_CODE> [<ISO_CODE> <ISO_CODE> ...]" >&2
exit 1
;;
esac
Expand Down
18 changes: 16 additions & 2 deletions build/i18n-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
PATTERN=$1
SCM=

echo $0 "initialises po/ i18n catalogues in empty language sub-folders."
echo $0 "is deprecated and may be removed in the future."
echo $(basename "$0") "initialises po/ i18n catalogues in empty language sub-folders."
echo $(basename "$0") "is deprecated and may be removed in the future."
echo "Hint: run i18n-add-language.sh instead."

[ -d .svn ] && SCM="svn"
Expand All @@ -18,6 +18,18 @@ git=$( command -v git 2>/dev/null )

[ -z "$PATTERN" ] && PATTERN="*.pot"

[ "${1#luci-}" ] && {
# user passed e.g. applications/luci-app-example - build template pot
path="${1%/}"
mkdir -p "$path/po/templates"
./build/i18n-scan.pl "$1" > "$1"/po/templates/"${path##*-}".pot && echo "Created $1/po/templates/${path##*-}.pot"
slashes="${path//[^\/]}/" # Keep only slashes
depth="${#slashes}" # Get the length of the remaining string (number of slashes)
prefix=$(printf '../%.0s' $(seq 1 "$depth"))
pushd "$path" 2&>/dev/null || exit
"$prefix"build/i18n-add-language.sh
}

for lang in $(cd po; echo ?? ??_??); do
for file in $(cd po/templates; echo $PATTERN); do
if [ -f po/templates/$file -a ! -f "po/$lang/${file%.pot}.po" ]; then
Expand All @@ -26,3 +38,5 @@ for lang in $(cd po; echo ?? ??_??); do
fi
done
done

popd 2&>/dev/null|| exit

0 comments on commit dc44c7a

Please sign in to comment.