blob: 6af7280fadc82ca17c7ea4237cac0a74007b94ad [file] [log] [blame]
[email protected]a2126d5e2009-08-24 16:43:041#!/usr/bin/env python
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
4# found in the LICENSE file.
5
6# TODO: remove this script when GYP has for loops
7
8import sys
[email protected]464dca72009-09-02 21:31:579import optparse
[email protected]a2126d5e2009-08-24 16:43:0410
11def main(argv):
[email protected]464dca72009-09-02 21:31:5712
13 parser = optparse.OptionParser()
14 usage = 'usage: %s [options ...] format_string locale_list'
15 parser.set_usage(usage.replace('%s', '%prog'))
16 parser.add_option('-d', dest='dash_to_underscore', action="store_true",
[email protected]e2260ed2009-11-04 14:42:1917 default=False,
18 help='map "en-US" to "en" and "-" to "_" in locales')
[email protected]464dca72009-09-02 21:31:5719
20 (options, arglist) = parser.parse_args(argv)
21
22 if len(arglist) < 3:
[email protected]a2126d5e2009-08-24 16:43:0423 print 'ERROR: need string and list of locales'
24 return 1
25
[email protected]464dca72009-09-02 21:31:5726 str_template = arglist[1]
27 locales = arglist[2:]
[email protected]a2126d5e2009-08-24 16:43:0428
29 results = []
30 for locale in locales:
[email protected]464dca72009-09-02 21:31:5731 # For Cocoa to find the locale at runtime, it needs to use '_' instead
[email protected]e2260ed2009-11-04 14:42:1932 # of '-' (http://crbug.com/20441). Also, 'en-US' should be represented
33 # simply as 'en' (http://crbug.com/19165, http://crbug.com/25578).
[email protected]464dca72009-09-02 21:31:5734 if options.dash_to_underscore:
[email protected]e2260ed2009-11-04 14:42:1935 if locale == 'en-US':
36 locale = 'en'
[email protected]464dca72009-09-02 21:31:5737 locale = locale.replace('-', '_')
[email protected]a2126d5e2009-08-24 16:43:0438 results.append(str_template.replace('ZZLOCALE', locale))
39
40 # Quote each element so filename spaces don't mess up GYP's attempt to parse
41 # it into a list.
[email protected]27ac03ee2009-09-02 18:55:5542 print ' '.join(["'%s'" % x for x in results])
[email protected]a2126d5e2009-08-24 16:43:0443
44if __name__ == '__main__':
45 sys.exit(main(sys.argv))