OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 '''The 'grit transl2tc' tool. | 6 '''The 'grit transl2tc' tool. |
7 ''' | 7 ''' |
8 | 8 |
9 | 9 |
10 import getopt | 10 import getopt |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 source_rc: Complete text of source RC file | 108 source_rc: Complete text of source RC file |
109 source_path: Path to the source RC file | 109 source_path: Path to the source RC file |
110 transl_rc: Complete text of translated RC file | 110 transl_rc: Complete text of translated RC file |
111 transl_path: Path to the translated RC file | 111 transl_path: Path to the translated RC file |
112 | 112 |
113 Return: | 113 Return: |
114 { id1 : text1, '12345678' : 'Hello USERNAME, howzit?' } | 114 { id1 : text1, '12345678' : 'Hello USERNAME, howzit?' } |
115 ''' | 115 ''' |
116 source_grd = self.rc2grd.Process(source_rc, source_path) | 116 source_grd = self.rc2grd.Process(source_rc, source_path) |
117 self.VerboseOut('Read %s into GRIT format, running gatherers.\n' % source_pa
th) | 117 self.VerboseOut('Read %s into GRIT format, running gatherers.\n' % source_pa
th) |
| 118 source_grd.SetOutputContext(current_grd.output_language, |
| 119 current_grd.defines) |
118 source_grd.RunGatherers(recursive=True, debug=self.o.extra_verbose) | 120 source_grd.RunGatherers(recursive=True, debug=self.o.extra_verbose) |
119 transl_grd = self.rc2grd.Process(transl_rc, transl_path) | 121 transl_grd = self.rc2grd.Process(transl_rc, transl_path) |
| 122 transl_grd.SetOutputContext(current_grd.output_language, |
| 123 current_grd.defines) |
120 self.VerboseOut('Read %s into GRIT format, running gatherers.\n' % transl_pa
th) | 124 self.VerboseOut('Read %s into GRIT format, running gatherers.\n' % transl_pa
th) |
121 transl_grd.RunGatherers(recursive=True, debug=self.o.extra_verbose) | 125 transl_grd.RunGatherers(recursive=True, debug=self.o.extra_verbose) |
122 self.VerboseOut('Done running gatherers for %s.\n' % transl_path) | 126 self.VerboseOut('Done running gatherers for %s.\n' % transl_path) |
123 | 127 |
124 # Proceed to create a map from ID to translation, getting the ID from the | 128 # Proceed to create a map from ID to translation, getting the ID from the |
125 # source GRD and the translation from the translated GRD. | 129 # source GRD and the translation from the translated GRD. |
126 id2transl = {} | 130 id2transl = {} |
127 for source_node in source_grd: | 131 for source_node in source_grd: |
128 source_cliques = source_node.GetCliques() | 132 source_cliques = source_node.GetCliques() |
129 if not len(source_cliques): | 133 if not len(source_cliques): |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 None | 249 None |
246 ''' | 250 ''' |
247 for id, text in translations: | 251 for id, text in translations: |
248 text = text.replace('<', '<').replace('>', '>') | 252 text = text.replace('<', '<').replace('>', '>') |
249 output_file.write(id) | 253 output_file.write(id) |
250 output_file.write(' ') | 254 output_file.write(' ') |
251 output_file.write(text) | 255 output_file.write(text) |
252 output_file.write('\n') | 256 output_file.write('\n') |
253 WriteTranslations = staticmethod(WriteTranslations) | 257 WriteTranslations = staticmethod(WriteTranslations) |
254 | 258 |
OLD | NEW |