diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2021-10-11 21:13:53 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2021-10-11 21:15:11 +0200 |
commit | b8e43c5d5a7f3854b630dc364fa380be7e98aec4 (patch) | |
tree | 314f591914408ce44dacb7d361d8f75907de5ef6 /po/make-template.sh | |
parent | e2790b42f3d33e5342af6948a21a48b6fdd5a22a (diff) | |
download | tdv-b8e43c5d5a7f3854b630dc364fa380be7e98aec4.tar.gz tdv-b8e43c5d5a7f3854b630dc364fa380be7e98aec4.tar.xz tdv-b8e43c5d5a7f3854b630dc364fa380be7e98aec4.zip |
make-template.sh: fix, improve, update, run
Diffstat (limited to 'po/make-template.sh')
-rwxr-xr-x | po/make-template.sh | 52 |
1 files changed, 12 insertions, 40 deletions
diff --git a/po/make-template.sh b/po/make-template.sh index f223841..8232e4d 100755 --- a/po/make-template.sh +++ b/po/make-template.sh @@ -1,47 +1,19 @@ -#!/bin/sh +#!/bin/sh -e # This shell script generates the translation template. # -# The reason for this not being inside CMakeLists.txt -# is that the translator should not need to run the whole -# configuration process just to get this single stupid file. - -# Get the directory this script resides in so that the user -# doesn't have to run the script from there -DIR=$(dirname $0) - -# Collect source files -SOURCES=$(echo $DIR/../src/*.c) - -# Get the package name from CMakeLists.txt -PACKAGE=$(sed -n '/^[ \t]*project[ \t]*([ \t]*\([^ \t)]\{1,\}\).*).*/{s//\1/p;q}' \ - $DIR/../CMakeLists.txt) - -# Get the package version from CMakeLists.txt -EXP_BEG='/^[ \t]*set[ \t]*([ \t]*project_VERSION_' -EXP_END='[ \t]\{1,\}"\{0,1\}\([^)"]\{1,\}\)"\{0,1\}).*/{s//\1/p;q}' - -MAJOR=$(sed -n "${EXP_BEG}MAJOR${EXP_END}" $DIR/../CMakeLists.txt) -MINOR=$(sed -n "${EXP_BEG}MINOR${EXP_END}" $DIR/../CMakeLists.txt) -PATCH=$(sed -n "${EXP_BEG}PATCH${EXP_END}" $DIR/../CMakeLists.txt) - -if [ "$MAJOR" != "" ]; then - VERSION=$MAJOR - if [ "$MINOR" != "" ]; then - VERSION=$VERSION.$MINOR - if [ "$PATCH" != "" ]; then - VERSION=$VERSION.$PATCH - fi - fi -fi - -if [ -z "$PACKAGE" -o -z "$VERSION" ]; then +# The reason for this not being inside CMakeLists.txt is that the translator +# should not need to run the whole configuration process just to get this file. +dir=$(dirname $0) + +re='^[ \t]*project *( *\([^ \t)]\{1,\}\) \{1,\}VERSION \{1,\}\([^ \t)]\{1,\}\).*' +package=$(sed -n "s/$re/\\1/p" "$dir/../CMakeLists.txt") +version=$(sed -n "s/$re/\\2/p" "$dir/../CMakeLists.txt") +if [ -z "$package" -o -z "$version" ]; then echo "Failed to get information from CMakeLists.txt" exit 1 fi -# Finally make the template -xgettext -LC -k_ -kN_ $SOURCES -o "$DIR/$PACKAGE.pot" \ - --package-name="$PACKAGE" --package-version="$VERSION" \ +xgettext -LC -k_ -kN_ $dir/../src/*.c -o "$dir/$package.pot" \ + --package-name="$package" --package-version="$version" \ --copyright-holder="Přemysl Eric Janouch" \ - --msgid-bugs-address="https://github.com/pjanouch/$PACKAGE/issues" - + --msgid-bugs-address="https://git.janouch.name/p/$package/issues" |