Skip to content

Instantly share code, notes, and snippets.

@flodolo
Created June 6, 2017 06:27
Show Gist options
  • Save flodolo/3d2b1040638a18f905f6980b92140b48 to your computer and use it in GitHub Desktop.
Save flodolo/3d2b1040638a18f905f6980b92140b48 to your computer and use it in GitHub Desktop.
Test compare-locales
import json
import subprocess
import sys
locales = [
'ach', 'af', 'an', 'ar', 'as', 'ast', 'az', 'be', 'bg', 'bn-BD', 'bn-IN', 'br',
'bs', 'ca', 'cak', 'cs', 'cy', 'da', 'de', 'dsb', 'el', 'en-GB', 'en-ZA', 'eo',
'es-AR', 'es-CL', 'es-ES', 'es-MX', 'et', 'eu', 'fa', 'ff', 'fi', 'fr', 'fy-NL',
'ga-IE', 'gd', 'gl', 'gn', 'gu-IN', 'he', 'hi-IN', 'hr', 'hsb', 'hu', 'hy-AM',
'id', 'is', 'it', 'ja', 'ja-JP-mac', 'ka', 'kab', 'kk', 'km', 'kn', 'ko', 'lij',
'lo', 'lt', 'ltg', 'lv', 'mai', 'mk', 'ml', 'mr', 'ms', 'my', 'nb-NO', 'ne-NP',
'nl', 'nn-NO', 'or', 'pa-IN', 'pl', 'pt-BR', 'pt-PT', 'rm', 'ro', 'ru', 'si',
'sk', 'sl', 'son', 'sq', 'sr', 'sv-SE', 'ta', 'te', 'th', 'tl', 'tr', 'trs',
'tsz', 'uk', 'ur', 'uz', 'vi', 'wo', 'xh', 'zam', 'zh-CN', 'zh-TW'
]
for locale in locales:
for p in ['browser', 'mobile/android']:
locale_stats = []
for t in ['ini', 'toml']:
commands = [
'compare-locales',
'/Users/flodolo/mozilla/mercurial/mozilla-unified/{}/locales/l10n.{}'.format(p, t),
'/Users/flodolo/mozilla/mercurial/l10n/',
locale,
'--data',
'json'
]
cmd_output = subprocess.check_output(commands, stderr=subprocess.STDOUT, shell=False)
try:
results = json.loads(cmd_output)
if not locale_stats:
locale_stats = results['summary'][locale]
else:
for k,v in results['summary'][locale].iteritems():
if k not in locale_stats or locale_stats[k] != v:
print 'Error: difference for {} ({} vs {}) in {}/{}'.format(k, v, locale_stats[k], locale, p)
except:
print e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment