From 6ce6e0fbb93b25f999a1a7115eeac561369c7f89 Mon Sep 17 00:00:00 2001 From: corleone77 Date: Sun, 11 Oct 2020 13:24:57 +0200 Subject: locorestrings style fixed Change-Id: If33d97ab9ddc33f5d674ddcc53db884338eb83c6 --- scripts/locorestrings.py | 58 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/scripts/locorestrings.py b/scripts/locorestrings.py index f1c819ba4a..78d79dd14d 100755 --- a/scripts/locorestrings.py +++ b/scripts/locorestrings.py @@ -10,6 +10,7 @@ import os import polib import sys + def usageAndExit(): message = """usage: {program} online_dir lo_translations_dir @@ -17,21 +18,27 @@ Translates style names, layout names, language names, etc. from LibreOffice files. """ - print(message.format(program = os.path.basename(sys.argv[0]))) + print(message.format(program=os.path.basename(sys.argv[0]))) exit(1) # extract translations from po files + + def extractFromPo(poFile, stringIds, translations): if not os.path.isfile(poFile): return - po = polib.pofile(poFile, autodetect_encoding=False, encoding="utf-8", wrapwidth=-1) + po = polib.pofile( + poFile, + autodetect_encoding=False, + encoding="utf-8", wrapwidth=-1) for entry in po.translated_entries(): for stringId in stringIds: if stringId in entry.msgctxt: translations[entry.msgid] = entry.msgstr + if __name__ == "__main__": if len(sys.argv) != 3: usageAndExit() @@ -46,24 +53,52 @@ if __name__ == "__main__": sys.stderr.write('Generating ' + lang + '...\n') - # extract 'Clear formatting', shape group names, and some status bar strings + # extract 'Clear formatting', shape group names, + # and some status bar strings poFile = dir + lang + '/svx/messages.po' - extractFromPo(poFile, ["RID_SVXSTR_CLEARFORM", "RID_SVXSTR_OVERWRITE_TEXT", "RID_SVXITEMS_PAGE_LAND_TRUE", "RID_SVXITEMS_PAGE_LAND_FALSE", "selectionmenu|", "defaultshapespanel|"], translations) + extractFromPo( + poFile, + ["RID_SVXSTR_CLEARFORM", + "RID_SVXSTR_OVERWRITE_TEXT", + "RID_SVXITEMS_PAGE_LAND_TRUE", + "RID_SVXITEMS_PAGE_LAND_FALSE", + "selectionmenu|", + "defaultshapespanel|"], translations) # extract Writer style names and status bar strings poFile = dir + lang + '/sw/messages.po' - extractFromPo(poFile, ["STR_POOL", "STR_PAGE_COUNT", "STR_STATUSBAR_WORDCOUNT_NO_SELECTION", "STR_LANGSTATUS_NONE"], translations) - - # extract Impress/Draw style names, layout names and 'Slide %1 of %2' + extractFromPo( + poFile, + ["STR_POOL", + "STR_PAGE_COUNT", + "STR_STATUSBAR_WORDCOUNT_NO_SELECTION", + "STR_LANGSTATUS_NONE"], translations) + + # extract Impress/Draw style names, + # layout names and 'Slide %1 of %2' poFile = dir + lang + '/sd/messages.po' - extractFromPo(poFile, ["STR_STANDARD_STYLESHEET_NAME", "STR_POOL", "STR_PSEUDOSHEET", "STR_AUTOLAYOUT", "STR_AL_", "STR_SD_PAGE_COUNT", "drawpagedialog|DrawPageDialog"], translations) + extractFromPo( + poFile, + ["STR_STANDARD_STYLESHEET_NAME", + "STR_POOL", "STR_PSEUDOSHEET", + "STR_AUTOLAYOUT", + "STR_AL_", + "STR_SD_PAGE_COUNT", + "drawpagedialog|DrawPageDialog"], translations) # extract Calc style names and strings for status bar poFile = dir + lang + '/sc/messages.po' - extractFromPo(poFile, ["STR_STYLENAME_", "STR_FILTER_SELCOUNT", "STR_ROWCOL_SELCOUNT", "STR_FUN_TEXT_", "STR_UNDO_INSERTCELLS", "STR_TABLE_COUNT"], translations) + extractFromPo( + poFile, + ["STR_STYLENAME_", + "STR_FILTER_SELCOUNT", + "STR_ROWCOL_SELCOUNT", + "STR_FUN_TEXT_", + "STR_UNDO_INSERTCELLS", + "STR_TABLE_COUNT"], translations) # extract Function Wizard name for formula bar - poFile = dir + lang +'/formula/messages.po' + poFile = dir + lang + '/formula/messages.po' extractFromPo(poFile, ["STR_TITLE1"], translations) # extract language names @@ -79,7 +114,8 @@ if __name__ == "__main__": f.write(',\n') else: writeComma = True - f.write(('"' + key + '":"' + translations[key] + '"').encode('utf-8')) + f.write( + ('"' + key + '":"' + translations[key] + '"').encode('utf-8')) f.write('\n}\n') -- cgit