blob: fcd02eb036af6e087bc2a508167c032918edcd35 [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
Raul Tambre9e24293b2019-05-12 06:11:078from __future__ import print_function
9
[email protected]a2126d5e2009-08-24 16:43:0410import sys
[email protected]464dca72009-09-02 21:31:5711import optparse
[email protected]a2126d5e2009-08-24 16:43:0412
13def main(argv):
[email protected]464dca72009-09-02 21:31:5714
15 parser = optparse.OptionParser()
16 usage = 'usage: %s [options ...] format_string locale_list'
17 parser.set_usage(usage.replace('%s', '%prog'))
18 parser.add_option('-d', dest='dash_to_underscore', action="store_true",
[email protected]e2260ed2009-11-04 14:42:1919 default=False,
20 help='map "en-US" to "en" and "-" to "_" in locales')
[email protected]464dca72009-09-02 21:31:5721
22 (options, arglist) = parser.parse_args(argv)
23
24 if len(arglist) < 3:
Raul Tambre9e24293b2019-05-12 06:11:0725 print('ERROR: need string and list of locales')
[email protected]a2126d5e2009-08-24 16:43:0426 return 1
27
[email protected]464dca72009-09-02 21:31:5728 str_template = arglist[1]
29 locales = arglist[2:]
[email protected]a2126d5e2009-08-24 16:43:0430
31 results = []
32 for locale in locales:
[email protected]464dca72009-09-02 21:31:5733 # For Cocoa to find the locale at runtime, it needs to use '_' instead
[email protected]e2260ed2009-11-04 14:42:1934 # of '-' (http://crbug.com/20441). Also, 'en-US' should be represented
35 # simply as 'en' (http://crbug.com/19165, http://crbug.com/25578).
[email protected]464dca72009-09-02 21:31:5736 if options.dash_to_underscore:
[email protected]e2260ed2009-11-04 14:42:1937 if locale == 'en-US':
38 locale = 'en'
[email protected]464dca72009-09-02 21:31:5739 locale = locale.replace('-', '_')
[email protected]a2126d5e2009-08-24 16:43:0440 results.append(str_template.replace('ZZLOCALE', locale))
41
42 # Quote each element so filename spaces don't mess up GYP's attempt to parse
43 # it into a list.
Raul Tambre9e24293b2019-05-12 06:11:0744 print(' '.join(["'%s'" % x for x in results]))
45
[email protected]a2126d5e2009-08-24 16:43:0446
47if __name__ == '__main__':
48 sys.exit(main(sys.argv))