OLD | NEW |
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. |
11 | 11 |
12 import os.path | 12 import os.path |
13 import plistlib | 13 import plistlib |
14 import subprocess | 14 import subprocess |
15 import sys | 15 import sys |
16 | 16 |
17 generate_localizer = "me" | 17 generate_localizer = "me" |
18 | 18 |
19 localizer_template_h = \ | 19 localizer_template_h = \ |
20 '''// ---------- WARNING ---------- | 20 '''// ---------- WARNING ---------- |
21 // THIS IS A GENERATED FILE, DO NOT EDIT IT DIRECTLY! | 21 // THIS IS A GENERATED FILE, DO NOT EDIT IT DIRECTLY! |
22 // | 22 // |
23 // Generated by %(generate_localizer)s. | 23 // Generated by %(generate_localizer)s. |
24 // Generated from %(xib_file)s. | 24 // Generated from %(xib_file)s. |
25 // | 25 // |
26 | 26 |
27 #ifndef %(class_name)s_LOCALIZER_H_ | 27 #ifndef %(class_name)s_LOCALIZER_H_ |
28 #define %(class_name)s_LOCALIZER_H_ | 28 #define %(class_name)s_LOCALIZER_H_ |
29 | 29 |
30 #import "third_party/GTM/AppKit/GTMUILocalizer.h" | 30 #import "chrome/browser/cocoa/ui_localizer.h" |
31 | 31 |
32 // A subclass of GTMUILocalizer that handles localizes based on resource | 32 // A subclass of ChromeUILocalizer that handles localization based on resource |
33 // constants. | 33 // constants. |
34 | 34 |
35 @interface %(class_name)sLocalizer : GTMUILocalizer { | 35 @interface %(class_name)sLocalizer : ChromeUILocalizer |
36 } | |
37 @end | 36 @end |
38 | 37 |
39 #endif // %(class_name)s_LOCALIZER_H_ | 38 #endif // %(class_name)s_LOCALIZER_H_ |
40 ''' | 39 ''' |
41 | 40 |
42 localizer_template_mm = \ | 41 localizer_template_mm = \ |
43 '''// ---------- WARNING ---------- | 42 '''// ---------- WARNING ---------- |
44 // THIS IS A GENERATED FILE, DO NOT EDIT IT DIRECTLY! | 43 // THIS IS A GENERATED FILE, DO NOT EDIT IT DIRECTLY! |
45 // | 44 // |
46 // Generated by '%(generate_localizer)s'. | 45 // Generated by '%(generate_localizer)s'. |
47 // Generated from '%(xib_file)s'. | 46 // Generated from '%(xib_file)s'. |
48 // | 47 // |
49 | 48 |
50 #import "%(header_name)s" | 49 #import "%(header_name)s" |
51 | 50 |
52 #import "chrome/browser/cocoa/ui_localizer.h" | |
53 #include "grit/chromium_strings.h" | 51 #include "grit/chromium_strings.h" |
54 #include "grit/generated_resources.h" | 52 #include "grit/generated_resources.h" |
55 | 53 |
56 @implementation %(class_name)sLocalizer | 54 @implementation %(class_name)sLocalizer |
57 | 55 |
58 - (NSString *)localizedStringForString:(NSString *)string { | 56 - (NSString *)localizedStringForString:(NSString *)string { |
59 | 57 |
60 static const ui_localizer::ResourceMap kUIResources[] = { | 58 static const ui_localizer::ResourceMap kUIResources[] = { |
61 %(resource_map_list)s }; | 59 %(resource_map_list)s }; |
62 static const size_t kUIResourcesSize = arraysize(kUIResources); | 60 static const size_t kUIResourcesSize = arraysize(kUIResources); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 file_fd.write(h_file_content) | 164 file_fd.write(h_file_content) |
167 file_fd.close() | 165 file_fd.close() |
168 file_fd = open(output_mm_path, 'w') | 166 file_fd = open(output_mm_path, 'w') |
169 file_fd.write(mm_file_content) | 167 file_fd.write(mm_file_content) |
170 file_fd.close() | 168 file_fd.close() |
171 | 169 |
172 return 0 | 170 return 0 |
173 | 171 |
174 if __name__ == '__main__': | 172 if __name__ == '__main__': |
175 sys.exit(Main(sys.argv)) | 173 sys.exit(Main(sys.argv)) |
OLD | NEW |