Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | #!/usr/bin/env python |
michael@0 | 2 | # Copyright (c) 2009 The Chromium Authors. All rights reserved. |
michael@0 | 3 | # Use of this source code is governed by a BSD-style license that can be |
michael@0 | 4 | # found in the LICENSE file. |
michael@0 | 5 | |
michael@0 | 6 | # TODO: remove this script when GYP has for loops |
michael@0 | 7 | |
michael@0 | 8 | import sys |
michael@0 | 9 | import optparse |
michael@0 | 10 | |
michael@0 | 11 | def main(argv): |
michael@0 | 12 | |
michael@0 | 13 | parser = optparse.OptionParser() |
michael@0 | 14 | usage = 'usage: %s [options ...] format_string locale_list' |
michael@0 | 15 | parser.set_usage(usage.replace('%s', '%prog')) |
michael@0 | 16 | parser.add_option('-d', dest='dash_to_underscore', action="store_true", |
michael@0 | 17 | default=False, |
michael@0 | 18 | help='map "en-US" to "en" and "-" to "_" in locales') |
michael@0 | 19 | |
michael@0 | 20 | (options, arglist) = parser.parse_args(argv) |
michael@0 | 21 | |
michael@0 | 22 | if len(arglist) < 3: |
michael@0 | 23 | print 'ERROR: need string and list of locales' |
michael@0 | 24 | return 1 |
michael@0 | 25 | |
michael@0 | 26 | str_template = arglist[1] |
michael@0 | 27 | locales = arglist[2:] |
michael@0 | 28 | |
michael@0 | 29 | results = [] |
michael@0 | 30 | for locale in locales: |
michael@0 | 31 | # For Cocoa to find the locale at runtime, it needs to use '_' instead |
michael@0 | 32 | # of '-' (http://crbug.com/20441). Also, 'en-US' should be represented |
michael@0 | 33 | # simply as 'en' (http://crbug.com/19165, http://crbug.com/25578). |
michael@0 | 34 | if options.dash_to_underscore: |
michael@0 | 35 | if locale == 'en-US': |
michael@0 | 36 | locale = 'en' |
michael@0 | 37 | locale = locale.replace('-', '_') |
michael@0 | 38 | results.append(str_template.replace('ZZLOCALE', locale)) |
michael@0 | 39 | |
michael@0 | 40 | # Quote each element so filename spaces don't mess up GYP's attempt to parse |
michael@0 | 41 | # it into a list. |
michael@0 | 42 | print ' '.join(["'%s'" % x for x in results]) |
michael@0 | 43 | |
michael@0 | 44 | if __name__ == '__main__': |
michael@0 | 45 | sys.exit(main(sys.argv)) |