media/webrtc/trunk/build/apply_locales.py

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/webrtc/trunk/build/apply_locales.py	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,45 @@
     1.4 +#!/usr/bin/env python
     1.5 +# Copyright (c) 2009 The Chromium Authors. All rights reserved.
     1.6 +# Use of this source code is governed by a BSD-style license that can be
     1.7 +# found in the LICENSE file.
     1.8 +
     1.9 +# TODO: remove this script when GYP has for loops
    1.10 +
    1.11 +import sys
    1.12 +import optparse
    1.13 +
    1.14 +def main(argv):
    1.15 +
    1.16 +  parser = optparse.OptionParser()
    1.17 +  usage = 'usage: %s [options ...] format_string locale_list'
    1.18 +  parser.set_usage(usage.replace('%s', '%prog'))
    1.19 +  parser.add_option('-d', dest='dash_to_underscore', action="store_true",
    1.20 +                    default=False,
    1.21 +                    help='map "en-US" to "en" and "-" to "_" in locales')
    1.22 +
    1.23 +  (options, arglist) = parser.parse_args(argv)
    1.24 +
    1.25 +  if len(arglist) < 3:
    1.26 +    print 'ERROR: need string and list of locales'
    1.27 +    return 1
    1.28 +
    1.29 +  str_template = arglist[1]
    1.30 +  locales = arglist[2:]
    1.31 +
    1.32 +  results = []
    1.33 +  for locale in locales:
    1.34 +    # For Cocoa to find the locale at runtime, it needs to use '_' instead
    1.35 +    # of '-' (http://crbug.com/20441).  Also, 'en-US' should be represented
    1.36 +    # simply as 'en' (http://crbug.com/19165, http://crbug.com/25578).
    1.37 +    if options.dash_to_underscore:
    1.38 +      if locale == 'en-US':
    1.39 +        locale = 'en'
    1.40 +      locale = locale.replace('-', '_')
    1.41 +    results.append(str_template.replace('ZZLOCALE', locale))
    1.42 +
    1.43 +  # Quote each element so filename spaces don't mess up GYP's attempt to parse
    1.44 +  # it into a list.
    1.45 +  print ' '.join(["'%s'" % x for x in results])
    1.46 +
    1.47 +if __name__ == '__main__':
    1.48 +  sys.exit(main(sys.argv))

mercurial