From 5c118ded7ce3ee1cee006ae64700219eefa01946 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sun, 21 Apr 2013 15:57:17 +0200 Subject: [PATCH] sandbox: Update check_trans.py to handle core locales. --- sandbox/check_trans.py | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/sandbox/check_trans.py b/sandbox/check_trans.py index a00416a78..feffd6476 100755 --- a/sandbox/check_trans.py +++ b/sandbox/check_trans.py @@ -2,14 +2,18 @@ import os import sys +import glob import subprocess def main(): directory = sys.argv[1] - for plugin in os.listdir(directory): - if plugin[0] not in 'AZERTYUIOPQSDFGHJKLMWXCVBN': - continue - checkPlugin(os.path.join(directory, plugin)) + if directory == '--core': + checkCore() + else: + for plugin in os.listdir(directory): + if plugin[0] not in 'AZERTYUIOPQSDFGHJKLMWXCVBN': + continue + checkPlugin(os.path.join(directory, plugin)) def changedir(f): def newf(new_path): @@ -21,6 +25,25 @@ def changedir(f): os.chdir(old_path) return newf +def checkCore(): + _checkCore(os.path.join(os.path.dirname(__file__), '..')) + +@changedir +def _checkCore(corePath): + subprocess.Popen(['pygettext', '-p', 'locales', 'plugins/__init__.py'] + glob.glob('src/*.py') + glob.glob('src/*/*.py')).wait() + localePath = os.path.join(corePath, 'locales') + pot = open(os.path.join(localePath, 'messages.pot')) + for translation in os.listdir(localePath): + if not translation.endswith('.po'): + continue + pot.seek(0) + potPath = os.path.join(os.getcwd(), 'locales', translation) + po = open(potPath) + if checkTranslation(pot, po): + print 'OK: ' + potPath + else: + print 'ERROR: ' + potPath + @changedir def checkPlugin(pluginPath):