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

Side by Side Diff: ios/chrome/tools/build/ios_repack_extension_locales.py

Issue 1774623004: Create localization files for iOS Share Extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: feedback Created 4 years, 9 months 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 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 """Helper script to repack paks for a list of locales for today extension. 6 """Helper script to repack paks for a list of locales for extensions.
7 7
8 Gyp doesn't have any built-in looping capability, so this just provides a way to 8 Gyp doesn't have any built-in looping capability, so this just provides a way to
9 loop over a list of locales when repacking pak files, thus avoiding a 9 loop over a list of locales when repacking pak files, thus avoiding a
10 proliferation of mostly duplicate, cut-n-paste gyp actions. 10 proliferation of mostly duplicate, cut-n-paste gyp actions.
11 """ 11 """
12 12
13 import optparse 13 import optparse
14 import os 14 import os
15 import sys 15 import sys
16 16
(...skipping 18 matching lines...) Expand all
35 locale = 'en' 35 locale = 'en'
36 else: 36 else:
37 locale = locale.replace('-', '_') 37 locale = locale.replace('-', '_')
38 return os.path.join(options.out_dir, locale + '.lproj', 'locale.pak') 38 return os.path.join(options.out_dir, locale + '.lproj', 'locale.pak')
39 39
40 40
41 def calc_inputs(options, locale): 41 def calc_inputs(options, locale):
42 """Determine the files that need processing for the given locale.""" 42 """Determine the files that need processing for the given locale."""
43 inputs = [] 43 inputs = []
44 44
45 #e.g. 'out/Debug/gen/ios/today_extension/ios_today_extension_strings_da.pak' 45 #e.g.
46 inputs.append(os.path.join(options.share_int_dir, 'ios', 'today_extension', 46 #'out/Debug/gen/ios/%(extension_name)/ios_%(extension_name)_strings_da.pak'
47 'ios_today_extension_strings_%s.pak' % (locale))) 47 inputs.append(os.path.join(options.share_int_dir, 'ios',
48 options.extension_name,
49 'ios_%s_strings_%s.pak' % (options.extension_name, locale)))
48 50
49 # Add any extra input files. 51 # Add any extra input files.
50 for extra_file in options.extra_input: 52 for extra_file in options.extra_input:
51 inputs.append('%s_%s.pak' % (extra_file, locale)) 53 inputs.append('%s_%s.pak' % (extra_file, locale))
52 54
53 return inputs 55 return inputs
54 56
55 57
56 def list_outputs(options, locales): 58 def list_outputs(options, locales):
57 """Returns the names of files that will be generated for the given locales. 59 """Returns the names of files that will be generated for the given locales.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 parser.add_option( 104 parser.add_option(
103 "-x", action="store", dest="out_dir", 105 "-x", action="store", dest="out_dir",
104 help="Intermediate build files output directory.") 106 help="Intermediate build files output directory.")
105 parser.add_option( 107 parser.add_option(
106 "-s", action="store", dest="share_int_dir", 108 "-s", action="store", dest="share_int_dir",
107 help="Shared intermediate build files output directory.") 109 help="Shared intermediate build files output directory.")
108 parser.add_option( 110 parser.add_option(
109 "-b", action="store", dest="branding", 111 "-b", action="store", dest="branding",
110 help="Branding type of this build.") 112 help="Branding type of this build.")
111 parser.add_option( 113 parser.add_option(
114 "-n", action="store", dest="extension_name",
115 help="Name of the extension.")
116 parser.add_option(
112 "-e", action="append", dest="extra_input", default=[], 117 "-e", action="append", dest="extra_input", default=[],
113 help="Full path to an extra input pak file without the " 118 help="Full path to an extra input pak file without the "
114 "locale suffix and \".pak\" extension.") 119 "locale suffix and \".pak\" extension.")
115 parser.add_option( 120 parser.add_option(
116 "--whitelist", action="store", help="Full path to the " 121 "--whitelist", action="store", help="Full path to the "
117 "whitelist used to filter output pak file resource IDs") 122 "whitelist used to filter output pak file resource IDs")
118 options, locales = parser.parse_args(argv) 123 options, locales = parser.parse_args(argv)
119 124
120 if not locales: 125 if not locales:
121 parser.error('Please specificy at least one locale to process.\n') 126 parser.error('Please specificy at least one locale to process.\n')
122 127
128 if not options.extension_name:
129 parser.error('Please specificy extension name.\n')
130
123 if not (options.out_dir and options.share_int_dir): 131 if not (options.out_dir and options.share_int_dir):
124 parser.error('Please specify all of "-x" and "-s".\n') 132 parser.error('Please specify all of "-x" and "-s".\n')
125 if options.print_inputs and options.print_outputs: 133 if options.print_inputs and options.print_outputs:
126 parser.error('Please specify only one of "-i" or "-o".\n') 134 parser.error('Please specify only one of "-i" or "-o".\n')
127 # Need to know the branding, unless we're just listing the outputs. 135 # Need to know the branding, unless we're just listing the outputs.
128 if not options.print_outputs and not options.branding: 136 if not options.print_outputs and not options.branding:
129 parser.error('Please specify "-b" to determine the input files.\n') 137 parser.error('Please specify "-b" to determine the input files.\n')
130 138
131 if options.print_inputs: 139 if options.print_inputs:
132 return quote_filenames(list_inputs(options, locales)) 140 return quote_filenames(list_inputs(options, locales))
133 141
134 if options.print_outputs: 142 if options.print_outputs:
135 return quote_filenames(list_outputs(options, locales)) 143 return quote_filenames(list_outputs(options, locales))
136 144
137 return repack_locales(options, locales) 145 return repack_locales(options, locales)
138 146
139 if __name__ == '__main__': 147 if __name__ == '__main__':
140 results = DoMain(sys.argv[1:]) 148 results = DoMain(sys.argv[1:])
141 if results: 149 if results:
142 print results 150 print results
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698