diff options
author | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-05 16:36:49 +0000 |
---|---|---|
committer | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-05 16:36:49 +0000 |
commit | bde080c9a95779cd781b051af838fa7784281e8e (patch) | |
tree | a132f5555c6ef1f9320754a29717143ebee6f3f8 /remoting | |
parent | d7b435d52e9bc68fc956c261164908b6d0282df4 (diff) | |
download | chromium_src-bde080c9a95779cd781b051af838fa7784281e8e.zip chromium_src-bde080c9a95779cd781b051af838fa7784281e8e.tar.gz chromium_src-bde080c9a95779cd781b051af838fa7784281e8e.tar.bz2 |
Add verify-translations.py script.
Review URL: http://codereview.chromium.org/8475019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108791 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rwxr-xr-x | remoting/webapp/verify-translations.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/remoting/webapp/verify-translations.py b/remoting/webapp/verify-translations.py new file mode 100755 index 0000000..65b253b --- /dev/null +++ b/remoting/webapp/verify-translations.py @@ -0,0 +1,49 @@ +#!/usr/bin/python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Verifies that the message tags in the 2nd and subsequent JSON message files +match those specified in the first. This is typically run when the +translations are updated before a release, to check that nothing got missed. +""" + +import json +import sys +import string + +def CheckTranslation(filename, translation, messages): + """Check |messages| for missing Ids in |translation|, and similarly for unused + Ids. If there are missing/unused Ids then report them and return failure. + """ + message_tags = set(map(string.lower, messages.keys())) + translation_tags = set(map(string.lower, translation.keys())) + if message_tags == translation_tags: + return True + + undefined_tags = message_tags - translation_tags + if undefined_tags: + print '%s: Missing: %s' % (filename, ", ".join(undefined_tags)) + + unused_tags = translation_tags - message_tags + if unused_tags: + print '%s: Unused: %s' % (filename, ", ".join(unused_tags)) + + return False + +def main(): + if len(sys.argv) < 3: + print 'Usage: verify-translations.py <messages> <translation-files...>' + sys.exit(1) + + en_messages = json.load(open(sys.argv[1], 'r')) + exit_code = 0 + for f in sys.argv[2:]: + translation = json.load(open(f, 'r')) + if not CheckTranslation(f, translation, en_messages): + exit_code = 1 + + sys.exit(exit_code) + +if __name__ == '__main__': + main() |