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

Side by Side Diff: build/mac/generate_localizer

Issue 165133: Bounce through a set so we uniq the string list to avoid having something lis... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2009 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2009 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 # Usage: generate_localizer [xib_path] [output_dot_h_path] [output_dot_mm_path] 7 # Usage: generate_localizer [xib_path] [output_dot_h_path] [output_dot_mm_path]
8 # 8 #
9 # Extracts all the localizable strings that start with "^IDS" from the given 9 # Extracts all the localizable strings that start with "^IDS" from the given
10 # xib file, and then generates a localizer to process those strings. 10 # xib file, and then generates a localizer to process those strings.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 if item_value.startswith('^IDS'): 90 if item_value.startswith('^IDS'):
91 constants_list.append(item_value) 91 constants_list.append(item_value)
92 elif item_value.startswith('IDS'): 92 elif item_value.startswith('IDS'):
93 sys.stderr.write( 93 sys.stderr.write(
94 '%s:0: warning: %s found a string with questionable prefix, "%s"\n' 94 '%s:0: warning: %s found a string with questionable prefix, "%s"\n'
95 % (xib_path, generate_localizer, item_value)); 95 % (xib_path, generate_localizer, item_value));
96 return constants_list 96 return constants_list
97 97
98 def generate_files_contents(class_name, constants_list, header_name, xib_path): 98 def generate_files_contents(class_name, constants_list, header_name, xib_path):
99 """Generates a localizer files contents from the list of constants.""" 99 """Generates a localizer files contents from the list of constants."""
100 # Copy and sort the list, then build the strings we need from it. 100 # Bounce through a set to uniq the strings, sort the list, then build the
101 constants_list = constants_list[:] 101 # values we need from it.
102 constants_list = list(set(constants_list))
102 constants_list.sort() 103 constants_list.sort()
Mark Mentovai 2009/08/07 16:38:48 Even better: constants_list = sorted(set(constant
103 constant_list_str = '' 104 constant_list_str = ''
104 for item in constants_list: 105 for item in constants_list:
105 parts = item.split('$', 1) 106 parts = item.split('$', 1)
106 label_id = parts[0] 107 label_id = parts[0]
107 if len(parts) == 2: 108 if len(parts) == 2:
108 label_arg_id = parts[1] 109 label_arg_id = parts[1]
109 else: 110 else:
110 label_arg_id = '0' 111 label_arg_id = '0'
111 constant_list_str += ' { "%s", %s, %s },\n' % \ 112 constant_list_str += ' { "%s", %s, %s },\n' % \
112 ( item, label_id[1:], label_arg_id) 113 ( item, label_id[1:], label_arg_id)
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 file_fd.write(h_file_content) 170 file_fd.write(h_file_content)
170 file_fd.close() 171 file_fd.close()
171 file_fd = open(output_mm_path, 'w') 172 file_fd = open(output_mm_path, 'w')
172 file_fd.write(mm_file_content) 173 file_fd.write(mm_file_content)
173 file_fd.close() 174 file_fd.close()
174 175
175 return 0 176 return 0
176 177
177 if __name__ == '__main__': 178 if __name__ == '__main__':
178 sys.exit(Main(sys.argv)) 179 sys.exit(Main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698