Browse Source

Add a $ at the end of the regex to rollback module to avoid breaking syntax. Definitely fix #4

master
LecygneNoir 5 years ago
parent
commit
a1136b6a55
1 changed files with 2 additions and 5 deletions
  1. +2
    -5
      rollback_module.sh

+ 2
- 5
rollback_module.sh View File

@ -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})

Loading…
Cancel
Save