sandbox: Update check_trans.py to handle core locales.

This commit is contained in:
Valentin Lorentz 2013-04-21 15:57:17 +02:00
parent d8df5cc650
commit 5c118ded7c

View File

@ -2,14 +2,18 @@
import os import os
import sys import sys
import glob
import subprocess import subprocess
def main(): def main():
directory = sys.argv[1] directory = sys.argv[1]
for plugin in os.listdir(directory): if directory == '--core':
if plugin[0] not in 'AZERTYUIOPQSDFGHJKLMWXCVBN': checkCore()
continue else:
checkPlugin(os.path.join(directory, plugin)) for plugin in os.listdir(directory):
if plugin[0] not in 'AZERTYUIOPQSDFGHJKLMWXCVBN':
continue
checkPlugin(os.path.join(directory, plugin))
def changedir(f): def changedir(f):
def newf(new_path): def newf(new_path):
@ -21,6 +25,25 @@ def changedir(f):
os.chdir(old_path) os.chdir(old_path)
return newf 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 @changedir
def checkPlugin(pluginPath): def checkPlugin(pluginPath):