Ren'Py Translator ToolKit  Check-in [0db75d0408]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:don't mark 'nvl clear' as OBSOLETE
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:0db75d040896f3fd6a1d636ef8b9ec2ab48c38bfaabe35269559f4ba96c29f4f
User & Date: Beuc 2020-07-25 16:16:37
Context
2020-07-25
16:24
Bump version Leaf check-in: f56a080400 user: Beuc tags: trunk
16:16
don't mark 'nvl clear' as OBSOLETE check-in: 0db75d0408 user: Beuc tags: trunk
2020-07-10
14:47
Use consistent plural check-in: b3847e36f0 user: Beuc tags: trunk
Changes

Changes to mo2tl.py.

203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
...
223
224
225
226
227
228
229



230
231
232
233
234
235
236
237
                                translation = None
                            else:
                                # unknown
                                pass
                            out.write(line)
                    else:
                        # dialog block
                        if o_blocks_index.get(msgid, None) is None:
                            obsolete = u"# OBSOLETE\n"
                            if last_comment != obsolete:
                                out.write(obsolete)
                        out.write(line)
                        while len(lines) > 0:
                            line = lines.pop()
                            if rttk.tlparser.is_empty(line):
................................................................................
                            elif rttk.tlparser.is_comment(line):
                                # untranslated original
                                pass
                            else:
                                # statement
                                s = rttk.tlparser.extract_dialog_string(line)
                                if s is None:



                                    # no double-quoted string, not a dialog line (e.g. nvl)
                                    pass
                                elif re.match('^\s*voice\s', line):
                                    # voice tag, not a dialog line
                                    pass
                                elif o_blocks_index.get(msgid, None) is None:
                                    # obsolete translate block, don't translate
                                    pass







|







 







>
>
>
|







203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
...
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
                                translation = None
                            else:
                                # unknown
                                pass
                            out.write(line)
                    else:
                        # dialog block
                        if not o_blocks_index.has_key(msgid):
                            obsolete = u"# OBSOLETE\n"
                            if last_comment != obsolete:
                                out.write(obsolete)
                        out.write(line)
                        while len(lines) > 0:
                            line = lines.pop()
                            if rttk.tlparser.is_empty(line):
................................................................................
                            elif rttk.tlparser.is_comment(line):
                                # untranslated original
                                pass
                            else:
                                # statement
                                s = rttk.tlparser.extract_dialog_string(line)
                                if s is None:
                                    # no ID (e.g. python block)
                                    pass
                                elif s['text'] is None:
                                    # no double-quoted string (e.g. nvl)
                                    pass
                                elif re.match('^\s*voice\s', line):
                                    # voice tag, not a dialog line
                                    pass
                                elif o_blocks_index.get(msgid, None) is None:
                                    # obsolete translate block, don't translate
                                    pass

Changes to rttk/test_tlparser.py.

120
121
122
123
124
125
126
127





128
129
130
131
132
133
134
translate russian tutorial_nvlmode_76b2fe88:

    # nvl clear
    nvl clear
"""
        lines = [l+"\n" for l in lines.split("\n")]
        lines.reverse()
        self.assertEqual(tlparser.parse_next_block(lines), [])






        lines = u"""
translate piglatin style default:
# comment but not the end of the bloc
    font "stonecutter.ttf"
"""
        lines = [l+"\n" for l in lines.split("\n")]







|
>
>
>
>
>







120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
translate russian tutorial_nvlmode_76b2fe88:

    # nvl clear
    nvl clear
"""
        lines = [l+"\n" for l in lines.split("\n")]
        lines.reverse()
        self.assertEqual(tlparser.parse_next_block(lines), [{
            'id': u'tutorial_nvlmode_76b2fe88',
            'source': None,
            'text': None,
            'translation': None
        }])

        lines = u"""
translate piglatin style default:
# comment but not the end of the bloc
    font "stonecutter.ttf"
"""
        lines = [l+"\n" for l in lines.split("\n")]

Changes to rttk/tlparser.py.

155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
                        continue
                    else:
                        # dialog body
                        s = extract_dialog_string(line)
                        if s is None:
                            continue  # not a dialog line
                        block_string['text'] = s['text']
                if block_string['text'] is not None:
                    ret = [block_string]
                break

        else:  # Unknown
            print("Warning: format not detected:", line)
            pass
    return ret







<
|






155
156
157
158
159
160
161

162
163
164
165
166
167
168
                        continue
                    else:
                        # dialog body
                        s = extract_dialog_string(line)
                        if s is None:
                            continue  # not a dialog line
                        block_string['text'] = s['text']

                ret = [block_string]
                break

        else:  # Unknown
            print("Warning: format not detected:", line)
            pass
    return ret

Changes to test/output_expected/script.rpy.

81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# game/script.rpy:53
translate french start_cb471577:

    # e "single-quoted \" string"
    e "chaîne de caractères entre guillemets simples dup2"

# game/script.rpy:56
# OBSOLETE
translate french start_76b2fe88:

    # nvl clear
    nvl clear

# game/script.rpy:59
translate french start_c9a35125:







<







81
82
83
84
85
86
87

88
89
90
91
92
93
94
# game/script.rpy:53
translate french start_cb471577:

    # e "single-quoted \" string"
    e "chaîne de caractères entre guillemets simples dup2"

# game/script.rpy:56

translate french start_76b2fe88:

    # nvl clear
    nvl clear

# game/script.rpy:59
translate french start_c9a35125:

Changes to tl2po.py.

57
58
59
60
61
62
63
64



65
66
67
68
69
70
71
    for curdir, subdirs, filenames in sorted(os.walk(os.path.join(projectpath,'game','tl','pot')), key=operator.itemgetter(0)):
        for filename in sorted(fnmatch.filter(filenames, '*.rpy')):
            print("Parsing  " + os.path.join(curdir,filename))
            f = io.open(os.path.join(curdir,filename), 'r', encoding='utf-8-sig')
            lines = f.readlines()
            lines.reverse()
            while len(lines) > 0:
                originals.extend(rttk.tlparser.parse_next_block(lines))




    translated = []
    for curdir, subdirs, filenames in os.walk(os.path.join(projectpath,'game','tl',language)):
        for filename in fnmatch.filter(filenames, '*.rpy'):
            print("Parsing  " + os.path.join(curdir,filename))
            f = io.open(os.path.join(curdir,filename), 'r', encoding='utf-8-sig')
            lines = f.readlines()







|
>
>
>







57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
    for curdir, subdirs, filenames in sorted(os.walk(os.path.join(projectpath,'game','tl','pot')), key=operator.itemgetter(0)):
        for filename in sorted(fnmatch.filter(filenames, '*.rpy')):
            print("Parsing  " + os.path.join(curdir,filename))
            f = io.open(os.path.join(curdir,filename), 'r', encoding='utf-8-sig')
            lines = f.readlines()
            lines.reverse()
            while len(lines) > 0:
                parsed = rttk.tlparser.parse_next_block(lines)
                for s in parsed:
                    if s['text'] is not None:
                        originals.append(s)

    translated = []
    for curdir, subdirs, filenames in os.walk(os.path.join(projectpath,'game','tl',language)):
        for filename in fnmatch.filter(filenames, '*.rpy'):
            print("Parsing  " + os.path.join(curdir,filename))
            f = io.open(os.path.join(curdir,filename), 'r', encoding='utf-8-sig')
            lines = f.readlines()

Changes to tl2pot.py.

46
47
48
49
50
51
52
53



54
55
56
57
58
59
60
        for filename in sorted(fnmatch.filter(filenames, '*.rpy')):
            print("Parsing  " + os.path.join(curdir,filename))
            f = io.open(os.path.join(curdir,filename), 'r', encoding='utf-8-sig')
            lines = f.readlines()
            lines.reverse()
            cur_strings = []
            while len(lines) > 0:
                cur_strings.extend(rttk.tlparser.parse_next_block(lines))



            cur_strings.sort(key=lambda s: (s['source'].split(':')[0], int(s['source'].split(':')[1])))
            strings.extend(cur_strings)
    
    occurrences = {}
    for s in strings:
        occurrences[s['text']] = occurrences.get(s['text'], 0) + 1








|
>
>
>







46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
        for filename in sorted(fnmatch.filter(filenames, '*.rpy')):
            print("Parsing  " + os.path.join(curdir,filename))
            f = io.open(os.path.join(curdir,filename), 'r', encoding='utf-8-sig')
            lines = f.readlines()
            lines.reverse()
            cur_strings = []
            while len(lines) > 0:
                parsed = rttk.tlparser.parse_next_block(lines)
                for s in parsed:
                    if s['text'] is not None:
                        cur_strings.append(s)
            cur_strings.sort(key=lambda s: (s['source'].split(':')[0], int(s['source'].split(':')[1])))
            strings.extend(cur_strings)
    
    occurrences = {}
    for s in strings:
        occurrences[s['text']] = occurrences.get(s['text'], 0) + 1