|
|
@ -22,7 +22,7 @@ TXT="${FINALDIR}/${TXT}" |
|
|
|
mkdir -p "${WORKDIR}" |
|
|
|
mkdir -p "${FINALDIR}" |
|
|
|
truncate -s 0 "${TXT}" |
|
|
|
readarray -t FILE < ${PO} |
|
|
|
readarray -t FILE < "${PO}" |
|
|
|
declare -A eventArray=() |
|
|
|
declare -A translationArray=() |
|
|
|
|
|
|
@ -36,7 +36,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}) |
|
|
@ -74,18 +74,18 @@ function rebuild_txt { |
|
|
|
sorted+=( "$key" ) |
|
|
|
done < <(printf '%s\0' "${!translationArray[@]}" | sort -zV) |
|
|
|
|
|
|
|
currentEvent=0 |
|
|
|
currentEvent="" |
|
|
|
currentNode="" |
|
|
|
for index in "${!eventArray[@]}"; do |
|
|
|
# If currentEvent is different than our index, then we just changed event and need to close the precedent |
|
|
|
# We also closed the next event in line |
|
|
|
if [[ ${currentEvent} != ${index} ]]; then |
|
|
|
echo "[/NODE]" >> ${TXT} |
|
|
|
echo >> ${TXT} |
|
|
|
echo "[/EVENT]" >> ${TXT} |
|
|
|
echo >> ${TXT} |
|
|
|
if [[ ${currentEvent} != ${index} && "${currentEvent}" != "" ]]; then |
|
|
|
echo "[/NODE]" >> "${TXT}" |
|
|
|
echo >> "${TXT}" |
|
|
|
echo "[/EVENT]" >> "${TXT}" |
|
|
|
echo >> "${TXT}" |
|
|
|
fi |
|
|
|
echo "${eventArray[${index}]}" >> ${TXT} |
|
|
|
echo "${eventArray[${index}]}" >> "${TXT}" |
|
|
|
for key in "${sorted[@]}"; do |
|
|
|
# We work only on key related to our current event |
|
|
|
if [[ "${key}" == "${index}"* ]]; then |
|
|
@ -95,28 +95,28 @@ function rebuild_txt { |
|
|
|
# If nodeID is different than currentNodeID, then we just changed the node and need to close the node |
|
|
|
# We do this only when we are in the same event and not for the first iteration |
|
|
|
if [[ "${currentNodeID}" != "${nodeID}" && ${currentEvent} == ${index} && "${currentNodeID}" != "" ]]; then |
|
|
|
echo "[/NODE]" >> ${TXT} |
|
|
|
echo >> ${TXT} |
|
|
|
echo "[/NODE]" >> "${TXT}" |
|
|
|
echo >> "${TXT}" |
|
|
|
fi |
|
|
|
# Here type is a story or an out |
|
|
|
if [[ "${type}" == "story" ]]; then |
|
|
|
echo "+[NODE]${nodeID}" >> ${TXT} |
|
|
|
echo "[STORY]" >> ${TXT} |
|
|
|
echo "${translationArray[${key}]}" >> ${TXT} |
|
|
|
echo "[/STORY]" >> ${TXT} |
|
|
|
echo "+[NODE]${nodeID}" >> "${TXT}" |
|
|
|
echo "[STORY]" >> "${TXT}" |
|
|
|
echo "${translationArray[${key}]}" >> "${TXT}" |
|
|
|
echo "[/STORY]" >> "${TXT}" |
|
|
|
currentNodeID=${nodeID} |
|
|
|
currentEvent=${index} |
|
|
|
else |
|
|
|
echo "[OUT]${translationArray[${key}]}" >> ${TXT} |
|
|
|
echo "[OUT]${translationArray[${key}]}" >> "${TXT}" |
|
|
|
fi |
|
|
|
fi |
|
|
|
done |
|
|
|
done |
|
|
|
# At the last of last event, we go outside the loop so we need to close remaining node and event |
|
|
|
echo "[/NODE]" >> ${TXT} |
|
|
|
echo >> ${TXT} |
|
|
|
echo "[/EVENT]" >> ${TXT} |
|
|
|
echo >> ${TXT} |
|
|
|
echo "[/NODE]" >> "${TXT}" |
|
|
|
echo >> "${TXT}" |
|
|
|
echo "[/EVENT]" >> "${TXT}" |
|
|
|
echo >> "${TXT}" |
|
|
|
} |
|
|
|
|
|
|
|
for index in "${!FILE[@]}"; do |
|
|
|