Browse Source

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

LecygneNoir 9 months ago
parent
commit
9defce2dcb
3 changed files with 35 additions and 10 deletions
  1. 1
    8
      README.md
  2. 21
    0
      extract_module.sh
  3. 13
    2
      rollback_module.sh

+ 1
- 8
README.md View File

@@ -44,12 +44,4 @@ To convert back from po:
44 44
 
45 45
 ```bash
46 46
 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)";
47
-```
48
-
49
-**Warning** : Empty events are not recreated (as they disappear on .pot), so be careful:
50
- - search for this in the Modules/game_files/*.txt
51
- ```bash
52
-\[/EVENT\]
53
-```
54
- - Report all empty events in the corresponding txt in Translation/modules
47
+```

+ 21
- 0
extract_module.sh View File

@@ -26,13 +26,18 @@ comment_event=""
26 26
 comment_node=""
27 27
 comment_story=""
28 28
 comment_out=""
29
+event_empty=0
29 30
 out_incr=1
30 31
 story_first_line=0
31 32
 while read -r line; do
32 33
     if  [[ ${line} == *"-- [EVENT]"* ]]; then
33 34
         comment_event="${line}"
35
+        # At start of event, we set event_empty just in case
36
+        event_empty=1
34 37
     elif [[ ${line} == *"+[NODE]"* ]]; then
35 38
         comment_node="${line}"
39
+        # At least one node, disable event_empty
40
+        event_empty=0
36 41
     elif [[ ${line} == *"[STORY]"* ]]; then
37 42
         comment_story="${comment_event}@@${comment_node}@@${line}"
38 43
         #Time for new story, write the comment to pot
@@ -62,6 +67,22 @@ while read -r line; do
62 67
         comment_story=""
63 68
         comment_out=""
64 69
         out_incr=1
70
+    elif [[ ${line} == *"[/EVENT]"* && ${event_empty} == 1 ]]; then
71
+        # We reach end of event and the event is empty, write special lines
72
+        comment_empty="${comment_event}EMPTY@@[EMPTY]0@@[EMPTY]0"
73
+        echo "#. ${comment_empty}" | tr -d '\r' | tr -d '\n' >> "${TEMP_POT}"
74
+        echo >> "${TEMP_POT}"
75
+        echo 'msgid "[SPECIAL EMPTY EVENT STRING]"' >> "${TEMP_POT}"
76
+        echo >> "${TEMP_POT}"
77
+        echo 'msgstr "[SPECIAL EMPTY EVENT STRING]"' >> "${TEMP_POT}"
78
+        echo >> "${TEMP_POT}"
79
+        # Then reinit
80
+        comment_event=""
81
+        comment_node=""
82
+        comment_story=""
83
+        comment_out=""
84
+        event_empty=0
85
+        out_incr=1
65 86
     elif [[ ${line} == *"[/EVENT]"* ]]; then
66 87
         # We reach end of event, reinit
67 88
         comment_event=""

+ 13
- 2
rollback_module.sh View File

@@ -75,16 +75,27 @@ function rebuild_txt {
75 75
 
76 76
     currentEvent=""
77 77
     currentNode=""
78
+    isEmpty=0
78 79
     for index in "${sortedEvent[@]}"; do
79 80
         # If currentEvent is different than our index, then we just changed event and need to close the precedent
80 81
         # We also closed the next event in line
81
-        if [[ ${currentEvent} != ${index} && "${currentEvent}" != "" ]]; then
82
+        if [[ ${currentEvent} != ${index} && "${currentEvent}" != "" && "${isEmpty}" != "1" ]]; then
82 83
             echo "[/NODE]" >> "${TXT}"
83 84
             echo >> "${TXT}"
84 85
             echo "[/EVENT]" >> "${TXT}"
85 86
             echo >> "${TXT}"
86 87
         fi
87
-        echo "${eventArray[${index}]}" >> "${TXT}"
88
+        echo "${eventArray[${index}]%EMPTY}" >> "${TXT}"
89
+        # If the Event contains EMPTY then it's a special empty event, we need to close it without le [/NODE]
90
+        # Then we pass directly to the next event
91
+        if [[ ${eventArray[${index}]} == *"EMPTY"* ]]; then
92
+                echo "[/EVENT]" >> "${TXT}"
93
+                echo >> "${TXT}"
94
+                isEmpty=1
95
+                currentEvent=${index}
96
+                continue
97
+        fi
98
+        isEmpty=0
88 99
         for key in "${sorted[@]}"; do
89 100
             # We work only on key related to our current event
90 101
             # We need to compare key to the event id in index, ie the first part of the key (see #7)

Loading…
Cancel
Save