Selaa lähdekoodia

Add the possibility to manage empty modules in the event .txt files, fix #10

master
LecygneNoir 4 vuotta sitten
vanhempi
commit
9defce2dcb
3 muutettua tiedostoa jossa 35 lisäystä ja 11 poistoa
  1. +1
    -9
      README.md
  2. +21
    -0
      extract_module.sh
  3. +13
    -2
      rollback_module.sh

+ 1
- 9
README.md Näytä tiedosto

@ -44,12 +44,4 @@ To convert back from po:
```bash
echo "start at $(date)"; time for i in Translation/fr/po/Modules/*; do echo "rollback ${i}..."; time ./rollback_module.sh "${i}" fr; echo "done"; done; echo "end at $(date)";
```
**Warning** : Empty events are not recreated (as they disappear on .pot), so be careful:
- search for this in the Modules/game_files/*.txt
```bash
-- \[EVENT\].*$
\[/EVENT\]
```
- Report all empty events in the corresponding txt in Translation/modules
```

+ 21
- 0
extract_module.sh Näytä tiedosto

@ -26,13 +26,18 @@ comment_event=""
comment_node=""
comment_story=""
comment_out=""
event_empty=0
out_incr=1
story_first_line=0
while read -r line; do
if [[ ${line} == *"-- [EVENT]"* ]]; then
comment_event="${line}"
# At start of event, we set event_empty just in case
event_empty=1
elif [[ ${line} == *"+[NODE]"* ]]; then
comment_node="${line}"
# At least one node, disable event_empty
event_empty=0
elif [[ ${line} == *"[STORY]"* ]]; then
comment_story="${comment_event}@@${comment_node}@@${line}"
#Time for new story, write the comment to pot
@ -62,6 +67,22 @@ while read -r line; do
comment_story=""
comment_out=""
out_incr=1
elif [[ ${line} == *"[/EVENT]"* && ${event_empty} == 1 ]]; then
# We reach end of event and the event is empty, write special lines
comment_empty="${comment_event}EMPTY@@[EMPTY]0@@[EMPTY]0"
echo "#. ${comment_empty}" | tr -d '\r' | tr -d '\n' >> "${TEMP_POT}"
echo >> "${TEMP_POT}"
echo 'msgid "[SPECIAL EMPTY EVENT STRING]"' >> "${TEMP_POT}"
echo >> "${TEMP_POT}"
echo 'msgstr "[SPECIAL EMPTY EVENT STRING]"' >> "${TEMP_POT}"
echo >> "${TEMP_POT}"
# Then reinit
comment_event=""
comment_node=""
comment_story=""
comment_out=""
event_empty=0
out_incr=1
elif [[ ${line} == *"[/EVENT]"* ]]; then
# We reach end of event, reinit
comment_event=""

+ 13
- 2
rollback_module.sh Näytä tiedosto

@ -75,16 +75,27 @@ function rebuild_txt {
currentEvent=""
currentNode=""
isEmpty=0
for index in "${sortedEvent[@]}"; 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} && "${currentEvent}" != "" ]]; then
if [[ ${currentEvent} != ${index} && "${currentEvent}" != "" && "${isEmpty}" != "1" ]]; then
echo "[/NODE]" >> "${TXT}"
echo >> "${TXT}"
echo "[/EVENT]" >> "${TXT}"
echo >> "${TXT}"
fi
echo "${eventArray[${index}]}" >> "${TXT}"
echo "${eventArray[${index}]%EMPTY}" >> "${TXT}"
# If the Event contains EMPTY then it's a special empty event, we need to close it without le [/NODE]
# Then we pass directly to the next event
if [[ ${eventArray[${index}]} == *"EMPTY"* ]]; then
echo "[/EVENT]" >> "${TXT}"
echo >> "${TXT}"
isEmpty=1
currentEvent=${index}
continue
fi
isEmpty=0
for key in "${sorted[@]}"; do
# We work only on key related to our current event
# We need to compare key to the event id in index, ie the first part of the key (see #7)

Ladataan…
Peruuta
Tallenna