From bc35bf285273744ebb10023ad0a6a7beae58a59e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Fri, 15 May 2020 02:20:24 +0200 Subject: tde-l10n_split_desktop: Adjusted to ensure portability + the use of an array is omitted + printf is used instead of echo + $(...) is used for subshell MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Slávek Banko --- conversions/tde-l10n/tde-l10n_split_desktop | 31 ++++++++++++++++------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/conversions/tde-l10n/tde-l10n_split_desktop b/conversions/tde-l10n/tde-l10n_split_desktop index e9831da..47bedaa 100755 --- a/conversions/tde-l10n/tde-l10n_split_desktop +++ b/conversions/tde-l10n/tde-l10n_split_desktop @@ -1,6 +1,6 @@ #!/bin/sh -# default keyword +# default keywords KEYWORDS="Name GenericName Comment Keywords Description ExtraNames X-TDE-Submenu" # parse arguments @@ -32,13 +32,16 @@ while [ $# -gt 0 ]; do *) [ -f "$1" ] && \ - D+=("$1") + D="${D}|$1" ;; esac shift done -set -- "${D[@]}" +oldIFS=$IFS +IFS="|" +set -- ${D#|} +IFS=$oldIFS if [ -z "$1" ]; then echo "No desktop file specified for processing. Exiting..." @@ -51,7 +54,7 @@ fi # determine path for translations TRANSLATIONS_DIR="translations/desktop_files" -if [ -n "`git rev-parse --git-dir 2>/dev/null`" ]; then +if [ -n "$(git rev-parse --git-dir 2>/dev/null)" ]; then TRANSLATIONS_DIR="$(git rev-parse --show-toplevel)/${TRANSLATIONS_DIR}" APPNAME=$(basename $(git rev-parse --show-toplevel)) fi @@ -106,7 +109,7 @@ done # extract strings #xgettext --foreign-user -L Desktop -k -k"Name" -k"GenericName" -k"Comment" -k"Keywords" -k"Description" -k"ExtraNames" -k"X-TDE-Submenu" -o - "$D" | \ -echo -n "${DX#|}" | tr "|" "\0" | xargs -r0 \ +printf "%s" "${DX#|}" | tr "|" "\0" | xargs -r0 \ xgettext --foreign-user -Cc -ki18n -o - | \ sed "s|\.tde_l10n||g" | \ sed "s|Content-Type: text/plain; charset=CHARSET|Content-Type: text/plain; charset=UTF-8|" \ @@ -114,38 +117,38 @@ sed "s|Content-Type: text/plain; charset=CHARSET|Content-Type: text/plain; chars POT_HEADER=$(sed -n "1,/^$/p" "$TRANSLATIONS_DIR/$POT") # remove temporary files -echo -n "${DX#|}" | tr "|" "\0" | xargs -r0 \ +printf "%s" "${DX#|}" | tr "|" "\0" | xargs -r0 \ rm # process languages -echo -n "${DO#|}" | tr "|" "\0" | xargs -r0 cat | +printf "%s" "${DO#|}" | tr "|" "\0" | xargs -r0 cat | sed -n "s|.*\[\([^]]*\)\][ ]*=.*|\1|p" | \ grep -vx "xx" | \ sort -u | \ while read L; do - echo "$POT_HEADER" | sed "s|\(Language: \)|\1$L|" > "$TRANSLATIONS_DIR/$L.po" - echo >> "$TRANSLATIONS_DIR/$L.po" + printf "%s\n" "$POT_HEADER" | sed "s|\(Language: \)|\1$L|" > "$TRANSLATIONS_DIR/$L.po" # process sections - echo "${DO#|}" | tr "|" "\n" | + printf "%s\n" "${DO#|}" | tr "|" "\n" | while read D; do sed -n "s|^\[\(.*\)\]$|\1|p" "$D" | \ while read S; do # process variables sed -n "/^\[$S\]/,/^\[/s|^\([^#\[][^\[]*\)\[$L\][ ]*=.*|\1|p" "$D" | \ while read V; do - MSGID=`sed -n -e "s|\"|\\\\\"|g" -e "/^\[$S\]/,/^\[/s|^$V[ ]*=[ ]*\(.*\)$|msgid \"\1\"|p" "$D"` + MSGID=$(sed -n -e "s|\"|\\\\\"|g" \ + -e "/^\[$S\]/,/^\[/s|^$V[ ]*=[ ]*\(.*\)$|msgid \"\1\"|p" "$D") if [ -n "$MSGID" ] && [ -z "$(grep -Fx "$MSGID" "$TRANSLATIONS_DIR/$L.po")" ]; then - echo "$MSGID" + printf "%s\n" "$MSGID" sed -n -e "s|\"|\\\\\"|g" -e "/^\[$S\]/,/^\[/s|^$V\[$L\][ ]*=[ ]*\(.*\)$|msgstr \"\1\"|p" "$D" | head -n1 - echo + printf "\n" fi done >> "$TRANSLATIONS_DIR/$L.po" done done # update according to template - echo -n "-- $L " + printf "%s" "-- $L " msgmerge --update --backup=none "$TRANSLATIONS_DIR/$L.po" "$TRANSLATIONS_DIR/$POT" done -- cgit v1.2.1