[Libreoffice-commits] online.git: 3 commits - scripts/untranslated.py
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Sun Oct 21 19:23:48 UTC 2018
scripts/untranslated.py | 136 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 136 insertions(+)
New commits:
commit 470960e60736ecb390aa3d6659e590b049ded56f
Author: Andras Timar <andras.timar at collabora.com>
AuthorDate: Sun Oct 21 21:22:04 2018 +0200
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Sun Oct 21 21:22:04 2018 +0200
adapth paths to new source layout
Change-Id: I26b99f697f8481783714d45793f49dd818164d60
diff --git a/scripts/untranslated.py b/scripts/untranslated.py
index 44c04f64b..5512f2344 100755
--- a/scripts/untranslated.py
+++ b/scripts/untranslated.py
@@ -39,7 +39,7 @@ def extractFromPo(poFile, stringIds, untranslated):
def parseUnocommandsJS(onlineDir):
strings = {}
- f = open(onlineDir + '/loleaflet/unocommands.js', 'r')
+ f = open(onlineDir + '/loleaflet/src/unocommands.js', 'r')
readingCommands = False
for line in f:
line = line.decode('utf-8')
@@ -73,46 +73,26 @@ if __name__ == "__main__":
# LO Core strings
- # extract 'Clear formatting'
- poFile = dir + lang + '/svx/source/tbxctrls.po'
- extractFromPo(poFile, ["RID_SVXSTR_CLEARFORM"], untranslated)
-
- # extract some status bar strings
- poFile = dir + lang + '/svx/source/stbctrls.po'
- stringIds = ["RID_SVXMENU_SELECTION", "RID_SVXSTR_OVERWRITE_TEXT"]
- extractFromPo(poFile, stringIds, untranslated)
- poFile = dir + lang + '/sw/source/ui/shells.po'
- extractFromPo(poFile, ["STR_PAGE_COUNT"], untranslated)
- poFile = dir + lang + '/sw/source/ui/app.po'
- extractFromPo(poFile, ["STR_STATUSBAR_WORDCOUNT_NO_SELECTION"], untranslated)
-
- # extract Writer style names
- poFile = dir + lang + '/sw/source/ui/utlui.po'
- extractFromPo(poFile, ["STR_POOL"], untranslated)
-
- # extract Impress/Draw style names
- poFile = dir + lang + '/sd/source/core.po'
- strengIds = ["STR_STANDARD_STYLESHEET_NAME", "STR_POOL", "STR_PSEUDOSHEET"]
- extractFromPo(poFile, stringIds, untranslated)
-
- # extract Impress layout names and 'Slide %1 of %2'
- poFile = dir + lang + '/sd/source/ui/app.po'
- stringIds = ["STR_AUTOLAYOUT", "STR_AL_", "STR_SD_PAGE_COUNT"]
- extractFromPo(poFile, stringIds, untranslated)
+ # extract 'Clear formatting' and some status bar strings
+ poFile = dir + lang + '/svx/messages.po'
+ extractFromPo(poFile, ["RID_SVXSTR_CLEARFORM", "RID_SVXSTR_OVERWRITE_TEXT", "selectionmenu|"], untranslated)
+
+ # 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"], untranslated)
+
+ # 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"], untranslated)
# extract Calc style names and strings for status bar
- poFile = dir + lang + '/sc/source/ui/src.po'
- stringIds = ["STR_STYLENAME_", "STR_FILTER_SELCOUNT", "STR_ROWCOL_SELCOUNT", "STR_FUN_TEXT_", "STR_UNDO_INSERTCELLS", "STR_TABLE_COUNT"]
- extractFromPo(poFile, stringIds, untranslated)
+ 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"], untranslated)
# extract language names
- poFile = dir + lang + '/svtools/source/misc.po'
+ poFile = dir + lang + '/svtools/messages.po'
extractFromPo(poFile, ["STR_ARR_SVT_LANGUAGE_TABLE"], untranslated)
- # extract 'None (Do not check spelling)'
- poFile = dir + lang + '/framework/source/classes.po'
- extractFromPo(poFile, ["STR_LANGSTATUS_NONE"], untranslated)
-
# UNO command strings
parsed = parseUnocommandsJS(onlineDir)
commit 03d184438e5a93bbe931d44ca797221cd7b36bfb
Author: Andras Timar <andras.timar at collabora.com>
AuthorDate: Thu Oct 18 15:36:30 2018 +0200
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Sun Oct 21 21:08:37 2018 +0200
typo: streingIds -> stringIds
Change-Id: If68d5ddb26eb8a9b1b1c9b13db3819972753aa28
diff --git a/scripts/untranslated.py b/scripts/untranslated.py
index 78d377f6f..44c04f64b 100755
--- a/scripts/untranslated.py
+++ b/scripts/untranslated.py
@@ -92,7 +92,7 @@ if __name__ == "__main__":
# extract Impress/Draw style names
poFile = dir + lang + '/sd/source/core.po'
- streingIds = ["STR_STANDARD_STYLESHEET_NAME", "STR_POOL", "STR_PSEUDOSHEET"]
+ strengIds = ["STR_STANDARD_STYLESHEET_NAME", "STR_POOL", "STR_PSEUDOSHEET"]
extractFromPo(poFile, stringIds, untranslated)
# extract Impress layout names and 'Slide %1 of %2'
commit 244b27170e6e8a5facbf775a411d0af4bd4df10d
Author: Andras Timar <andras.timar at collabora.com>
AuthorDate: Mon Jul 30 23:44:27 2018 +0200
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Sun Oct 21 21:07:59 2018 +0200
untranslated.py - a helper script to list untranslated strings for a given language
Change-Id: I44d5102fbe3ca319d5a4671a91957353c5357cda
diff --git a/scripts/untranslated.py b/scripts/untranslated.py
new file mode 100755
index 000000000..78d377f6f
--- /dev/null
+++ b/scripts/untranslated.py
@@ -0,0 +1,156 @@
+#!/usr/bin/env python
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+import os
+import polib
+import sys
+import itertools
+import re
+
+def usageAndExit():
+ message = """usage: {program} online_dir lo_translations_dir lang
+
+Prints en-US strings that do not have translations in the specified language.
+
+"""
+ print(message.format(program = os.path.basename(sys.argv[0])))
+ exit(1)
+
+# extract translations from po files
+def extractFromPo(poFile, stringIds, untranslated):
+ if not os.path.isfile(poFile):
+ return
+
+ po = polib.pofile(poFile, autodetect_encoding=False, encoding="utf-8", wrapwidth=-1)
+
+ for entry in itertools.chain(po.untranslated_entries(), po.fuzzy_entries()):
+ for stringId in stringIds:
+ if stringId in entry.msgctxt:
+ untranslated.append(entry.msgid)
+
+# Read the uno commands present in the unocommands.js for checking
+def parseUnocommandsJS(onlineDir):
+ strings = {}
+
+ f = open(onlineDir + '/loleaflet/unocommands.js', 'r')
+ readingCommands = False
+ for line in f:
+ line = line.decode('utf-8')
+ m = re.match(r"\t([^:]*):.*", line)
+ if m:
+ command = m.group(1)
+
+ n = re.findall(r"_\('([^']*)'\)", line)
+ if n:
+ strings[command] = n
+
+ return strings
+
+# Remove duplicates from list
+def uniq(seq):
+ seen = set()
+ seen_add = seen.add
+ return [x for x in seq if not (x in seen or seen_add(x))]
+
+if __name__ == "__main__":
+ if len(sys.argv) != 4:
+ usageAndExit()
+
+ onlineDir = sys.argv[1]
+ translationsDir = sys.argv[2]
+ lang = sys.argv[3]
+
+ dir = translationsDir + '/source/'
+
+ untranslated = []
+
+# LO Core strings
+
+ # extract 'Clear formatting'
+ poFile = dir + lang + '/svx/source/tbxctrls.po'
+ extractFromPo(poFile, ["RID_SVXSTR_CLEARFORM"], untranslated)
+
+ # extract some status bar strings
+ poFile = dir + lang + '/svx/source/stbctrls.po'
+ stringIds = ["RID_SVXMENU_SELECTION", "RID_SVXSTR_OVERWRITE_TEXT"]
+ extractFromPo(poFile, stringIds, untranslated)
+ poFile = dir + lang + '/sw/source/ui/shells.po'
+ extractFromPo(poFile, ["STR_PAGE_COUNT"], untranslated)
+ poFile = dir + lang + '/sw/source/ui/app.po'
+ extractFromPo(poFile, ["STR_STATUSBAR_WORDCOUNT_NO_SELECTION"], untranslated)
+
+ # extract Writer style names
+ poFile = dir + lang + '/sw/source/ui/utlui.po'
+ extractFromPo(poFile, ["STR_POOL"], untranslated)
+
+ # extract Impress/Draw style names
+ poFile = dir + lang + '/sd/source/core.po'
+ streingIds = ["STR_STANDARD_STYLESHEET_NAME", "STR_POOL", "STR_PSEUDOSHEET"]
+ extractFromPo(poFile, stringIds, untranslated)
+
+ # extract Impress layout names and 'Slide %1 of %2'
+ poFile = dir + lang + '/sd/source/ui/app.po'
+ stringIds = ["STR_AUTOLAYOUT", "STR_AL_", "STR_SD_PAGE_COUNT"]
+ extractFromPo(poFile, stringIds, untranslated)
+
+ # extract Calc style names and strings for status bar
+ poFile = dir + lang + '/sc/source/ui/src.po'
+ stringIds = ["STR_STYLENAME_", "STR_FILTER_SELCOUNT", "STR_ROWCOL_SELCOUNT", "STR_FUN_TEXT_", "STR_UNDO_INSERTCELLS", "STR_TABLE_COUNT"]
+ extractFromPo(poFile, stringIds, untranslated)
+
+ # extract language names
+ poFile = dir + lang + '/svtools/source/misc.po'
+ extractFromPo(poFile, ["STR_ARR_SVT_LANGUAGE_TABLE"], untranslated)
+
+ # extract 'None (Do not check spelling)'
+ poFile = dir + lang + '/framework/source/classes.po'
+ extractFromPo(poFile, ["STR_LANGSTATUS_NONE"], untranslated)
+
+# UNO command strings
+
+ parsed = parseUnocommandsJS(onlineDir)
+ keys = set(parsed.keys())
+
+ poFile = dir + lang + '/officecfg/registry/data/org/openoffice/Office/UI.po'
+
+ po = polib.pofile(poFile, autodetect_encoding=False, encoding="utf-8", wrapwidth=-1)
+
+ for entry in itertools.chain(po.untranslated_entries(), po.fuzzy_entries()):
+ m = re.search(r"\.uno:([^\n]*)\n", entry.msgctxt)
+ if m:
+ command = m.group(1)
+ if command in keys:
+ for text in parsed[command]:
+ if text == entry.msgid:
+ untranslated.append(entry.msgid.replace("~",""))
+
+# Online UI
+
+ poFile = onlineDir + '/loleaflet/po/ui-' + lang.replace("-","_") + '.po'
+ po = polib.pofile(poFile, autodetect_encoding=False, encoding="utf-8", wrapwidth=-1)
+
+ for entry in itertools.chain(po.untranslated_entries(), po.fuzzy_entries()):
+ untranslated.append(entry.msgid)
+
+# Online help (keyboard shortcuts)
+
+ poFile = onlineDir + '/loleaflet/po/help-' + lang.replace("-","_") + '.po'
+ po = polib.pofile(poFile, autodetect_encoding=False, encoding="utf-8", wrapwidth=-1)
+
+ for entry in itertools.chain(po.untranslated_entries(), po.fuzzy_entries()):
+ untranslated.append(entry.msgid)
+
+# Print the results
+
+ for elem in uniq(untranslated):
+ print elem.encode('utf-8')
+
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
More information about the Libreoffice-commits
mailing list