diff --git a/prelude.yaml b/prelude.yaml index 7790d6c..80fd298 100644 --- a/prelude.yaml +++ b/prelude.yaml @@ -2580,6 +2580,8 @@ common: text: '**{0}** kullanıyor gibi görünüyorsunuz, ancak bu artık geçersiz. Bunun yerine **{1}** kullanmanız tavsiye edilir.' - lang: uk_UA text: 'Здається, ви використовуєте **{0}**, але його було замінено. Радимо використовувати **{1}** замість нього.' + - lang: zh_CN + text: '您似乎正在使用 **{0}**,但它已受到取代。推荐您使用 **{1}**。' subs: - 'xSE Plugin 0' - 'xSE Plugin 1' diff --git a/scripts/import-translations.py b/scripts/import-translations.py index 2fc3305..3763b38 100644 --- a/scripts/import-translations.py +++ b/scripts/import-translations.py @@ -40,6 +40,22 @@ def insert_lang(lines, index, lang, raw_text, whitespace = None): lines.insert(index, new_text_line) lines.insert(index, new_lang_line) +def append_missing_languages(messages, lines, anchor, last_lang_index, expected_langs): + # Expected more languages than were found in the last anchor, + # need to go back and append the remaining expected languages. + print(f'Expected more languages for anchor {anchor}: {expected_langs}') + + whitespace = get_whitespace(lines[last_lang_index]) + + for expected_lang in expected_langs: + print(f'Appending language {expected_lang} to anchor {anchor}') + + insert_lang(lines, last_lang_index + 2, expected_lang, messages[anchor][expected_lang], whitespace) + + last_lang_index += 2 + + return last_lang_index + messages_by_lang = {} for f in os.scandir('translations'): match = re.match(r'messages\.([^\.]+)\.yaml', f.name) @@ -68,18 +84,7 @@ with open('prelude.yaml', encoding='utf8') as input: match = re.search(r' &([^\s]+)$', lines[index]) if match != None: if expected_langs: - # Expected more languages than were found in the last anchor, - # need to go back and append the remaining expected languages. - print(f'Expected more languages for anchor {anchor}: {expected_langs}') - - whitespace = get_whitespace(lines[last_lang_index]) - - for expected_lang in expected_langs: - print(f'Appending language {expected_lang} to anchor {anchor}') - - insert_lang(lines, last_lang_index + 2, expected_lang, messages[anchor][expected_lang], whitespace) - - last_lang_index += 2 + last_lang_index = append_missing_languages(messages, lines, anchor, last_lang_index, expected_langs) index += 2 * len(expected_langs) @@ -117,5 +122,9 @@ with open('prelude.yaml', encoding='utf8') as input: index += 1 + if expected_langs: + # The last anchor has missing languages, go back and add them. + append_missing_languages(messages, lines, anchor, last_lang_index, expected_langs) + with open('prelude.yaml', mode='w', encoding='utf8') as output: output.writelines(lines)