Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: chrome/tools/build/apply_locales.py

Issue 345057: EN, mf, DO YOU SPEAK IT? (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/chrome.gyp ('k') | chrome/tools/build/mac/symlink_lprojs » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 # TODO: remove this script when GYP has for loops 6 # TODO: remove this script when GYP has for loops
7 7
8 import sys 8 import sys
9 import optparse 9 import optparse
10 10
11 def main(argv): 11 def main(argv):
12 12
13 parser = optparse.OptionParser() 13 parser = optparse.OptionParser()
14 usage = 'usage: %s [options ...] format_string locale_list' 14 usage = 'usage: %s [options ...] format_string locale_list'
15 parser.set_usage(usage.replace('%s', '%prog')) 15 parser.set_usage(usage.replace('%s', '%prog'))
16 parser.add_option('-d', dest='dash_to_underscore', action="store_true", 16 parser.add_option('-d', dest='dash_to_underscore', action="store_true",
17 default=False, help='map "-" to "_" in locales') 17 default=False,
18 help='map "en-US" to "en" and "-" to "_" in locales')
18 19
19 (options, arglist) = parser.parse_args(argv) 20 (options, arglist) = parser.parse_args(argv)
20 21
21 if len(arglist) < 3: 22 if len(arglist) < 3:
22 print 'ERROR: need string and list of locales' 23 print 'ERROR: need string and list of locales'
23 return 1 24 return 1
24 25
25 str_template = arglist[1] 26 str_template = arglist[1]
26 locales = arglist[2:] 27 locales = arglist[2:]
27 28
28 results = [] 29 results = []
29 for locale in locales: 30 for locale in locales:
30 # For Cocoa to find the locale at runtime, it needs to use '_' instead 31 # For Cocoa to find the locale at runtime, it needs to use '_' instead
31 # of '-'. (http://crbug.com/20441) 32 # of '-' (http://crbug.com/20441). Also, 'en-US' should be represented
33 # simply as 'en' (http://crbug.com/19165, http://crbug.com/25578).
32 if options.dash_to_underscore: 34 if options.dash_to_underscore:
35 if locale == 'en-US':
36 locale = 'en'
33 locale = locale.replace('-', '_') 37 locale = locale.replace('-', '_')
34 results.append(str_template.replace('ZZLOCALE', locale)) 38 results.append(str_template.replace('ZZLOCALE', locale))
35 39
36 # Quote each element so filename spaces don't mess up GYP's attempt to parse 40 # Quote each element so filename spaces don't mess up GYP's attempt to parse
37 # it into a list. 41 # it into a list.
38 print ' '.join(["'%s'" % x for x in results]) 42 print ' '.join(["'%s'" % x for x in results])
39 43
40 if __name__ == '__main__': 44 if __name__ == '__main__':
41 sys.exit(main(sys.argv)) 45 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « chrome/chrome.gyp ('k') | chrome/tools/build/mac/symlink_lprojs » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698