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

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: 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 extension.
sdefresne 2016/03/10 13:48:33 nit: extension -> extensions
Olivier 2016/03/10 14:31:15 Done.
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. 'out/Debug/gen/ios/%extension_name%/ios_%extension_name%_strings_da.pak'
sdefresne 2016/03/10 13:48:33 nit: %variable% is unusual on un*x, can you change
Olivier 2016/03/10 14:31:16 Done.
46 inputs.append(os.path.join(options.share_int_dir, 'ios', 'today_extension', 46 inputs.append(os.path.join(
sdefresne 2016/03/10 13:48:33 nit: keep the original formatting inputs.append
Olivier 2016/03/10 14:31:15 It does not fit, so I put it on next line.
47 'ios_today_extension_strings_%s.pak' % (locale))) 47 options.share_int_dir,
48 'ios',
49 options.extension_name,
50 'ios_%s_strings_%s.pak' % (options.extension_name, locale)))
48 51
49 # Add any extra input files. 52 # Add any extra input files.
50 for extra_file in options.extra_input: 53 for extra_file in options.extra_input:
51 inputs.append('%s_%s.pak' % (extra_file, locale)) 54 inputs.append('%s_%s.pak' % (extra_file, locale))
52 55
53 return inputs 56 return inputs
54 57
55 58
56 def list_outputs(options, locales): 59 def list_outputs(options, locales):
57 """Returns the names of files that will be generated for the given locales. 60 """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( 105 parser.add_option(
103 "-x", action="store", dest="out_dir", 106 "-x", action="store", dest="out_dir",
104 help="Intermediate build files output directory.") 107 help="Intermediate build files output directory.")
105 parser.add_option( 108 parser.add_option(
106 "-s", action="store", dest="share_int_dir", 109 "-s", action="store", dest="share_int_dir",
107 help="Shared intermediate build files output directory.") 110 help="Shared intermediate build files output directory.")
108 parser.add_option( 111 parser.add_option(
109 "-b", action="store", dest="branding", 112 "-b", action="store", dest="branding",
110 help="Branding type of this build.") 113 help="Branding type of this build.")
111 parser.add_option( 114 parser.add_option(
115 "-n", action="store", dest="extension_name",
116 help="Name of the extension.")
117 parser.add_option(
112 "-e", action="append", dest="extra_input", default=[], 118 "-e", action="append", dest="extra_input", default=[],
113 help="Full path to an extra input pak file without the " 119 help="Full path to an extra input pak file without the "
114 "locale suffix and \".pak\" extension.") 120 "locale suffix and \".pak\" extension.")
115 parser.add_option( 121 parser.add_option(
116 "--whitelist", action="store", help="Full path to the " 122 "--whitelist", action="store", help="Full path to the "
117 "whitelist used to filter output pak file resource IDs") 123 "whitelist used to filter output pak file resource IDs")
118 options, locales = parser.parse_args(argv) 124 options, locales = parser.parse_args(argv)
119 125
120 if not locales: 126 if not locales:
121 parser.error('Please specificy at least one locale to process.\n') 127 parser.error('Please specificy at least one locale to process.\n')
122 128
129 if not options.extension_name:
130 parser.error('Please specificy extension name.\n')
131
123 if not (options.out_dir and options.share_int_dir): 132 if not (options.out_dir and options.share_int_dir):
124 parser.error('Please specify all of "-x" and "-s".\n') 133 parser.error('Please specify all of "-x" and "-s".\n')
125 if options.print_inputs and options.print_outputs: 134 if options.print_inputs and options.print_outputs:
126 parser.error('Please specify only one of "-i" or "-o".\n') 135 parser.error('Please specify only one of "-i" or "-o".\n')
127 # Need to know the branding, unless we're just listing the outputs. 136 # Need to know the branding, unless we're just listing the outputs.
128 if not options.print_outputs and not options.branding: 137 if not options.print_outputs and not options.branding:
129 parser.error('Please specify "-b" to determine the input files.\n') 138 parser.error('Please specify "-b" to determine the input files.\n')
130 139
131 if options.print_inputs: 140 if options.print_inputs:
132 return quote_filenames(list_inputs(options, locales)) 141 return quote_filenames(list_inputs(options, locales))
133 142
134 if options.print_outputs: 143 if options.print_outputs:
135 return quote_filenames(list_outputs(options, locales)) 144 return quote_filenames(list_outputs(options, locales))
136 145
137 return repack_locales(options, locales) 146 return repack_locales(options, locales)
138 147
139 if __name__ == '__main__': 148 if __name__ == '__main__':
140 results = DoMain(sys.argv[1:]) 149 results = DoMain(sys.argv[1:])
141 if results: 150 if results:
142 print results 151 print results
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698