diff --git a/rollback_module.sh b/rollback_module.sh index 68452b6..2364b95 100755 --- a/rollback_module.sh +++ b/rollback_module.sh @@ -1,9 +1,5 @@ #!/bin/bash -# to add document to zanata, extract .pot with: -# grep Key DATABASE_UI_LOCALIZATION.xml | awk -F'"' '{print "#. "$2"\n" "msgid " "\""$4"\"" "\n" "msgstr " "\"\""}' > DATABASE_UI_LOCALIZATION.pot -# then pass the .pot in poedit to merge duplication and add the Zanata header - if [[ "$#" -ne 2 ]]; then echo "Please pass exactly 2 parameters: the .po and the language" exit 1 @@ -17,6 +13,7 @@ FINALDIR="$(pwd)/Translation/${LANGUAGE}/game_files/Modules/" TXT=$(basename "${PO%%.po}.txt") TXT="${FINALDIR}/${TXT}" +dos2unix "${PO}" &> /dev/null # Initialization mkdir -p "${WORKDIR}" @@ -36,7 +33,7 @@ function extract_translation { key="${key//+/\\\\\+}" key="${key//(/\\\\\(}" # We search for the exact key in the po file until we get a blank line, to get the full msgstr and the msgid - tempPO=$(awk -v key="${key}" '{pat="#. "key""} !NF{s=0}s;$0 ~ pat{ print $0; s=1 }' "${PO}") + tempPO=$(awk -v key="${key}" '{pat="#. "key"$"} !NF{s=0}s;$0 ~ pat{ print $0; s=1 }' "${PO}") # Extract msgstr and merge all lines into one tempMsgstr=$(awk '!NF{s=0}s;/msgstr/{ print $0; s=1 }' <<< "${tempPO}" | sed -e 's/^"//' -e 's/"$//' -e 's/^msgstr "//') msgstr=$(awk 'NR{printf "%s",$0;next;}1' <<< ${tempMsgstr})