| 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 android2grd' tool.""" | 6 """The 'grit android2grd' tool.""" |
| 7 | 7 |
| 8 | 8 |
| 9 import getopt | 9 import getopt |
| 10 import os.path | 10 import os.path |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 string.xml document. | 187 string.xml document. |
| 188 Returns: | 188 Returns: |
| 189 The DOM for the grd xml document produced by converting the Android DOM. | 189 The DOM for the grd xml document produced by converting the Android DOM. |
| 190 """ | 190 """ |
| 191 | 191 |
| 192 # Start with a basic skeleton for the .grd file. | 192 # Start with a basic skeleton for the .grd file. |
| 193 root = grd_reader.Parse(StringIO.StringIO( | 193 root = grd_reader.Parse(StringIO.StringIO( |
| 194 '''<?xml version="1.0" encoding="UTF-8"?> | 194 '''<?xml version="1.0" encoding="UTF-8"?> |
| 195 <grit base_dir="." latest_public_release="0" | 195 <grit base_dir="." latest_public_release="0" |
| 196 current_release="1" source_lang_id="en"> | 196 current_release="1" source_lang_id="en"> |
| 197 <outputs /> |
| 198 <translations /> |
| 197 <release allow_pseudo="false" seq="1"> | 199 <release allow_pseudo="false" seq="1"> |
| 198 <messages fallback_to_english="true" /> | 200 <messages fallback_to_english="true" /> |
| 199 </release> | 201 </release> |
| 200 <translations /> | |
| 201 <outputs /> | |
| 202 </grit>'''), dir='.') | 202 </grit>'''), dir='.') |
| 203 messages = root.children[0].children[0] | 203 outputs = root.children[0] |
| 204 translations = root.children[1] | 204 translations = root.children[1] |
| 205 outputs = root.children[2] | 205 messages = root.children[2].children[0] |
| 206 assert (isinstance(messages, grit.node.empty.MessagesNode) and | 206 assert (isinstance(messages, grit.node.empty.MessagesNode) and |
| 207 isinstance(translations, grit.node.empty.TranslationsNode) and | 207 isinstance(translations, grit.node.empty.TranslationsNode) and |
| 208 isinstance(outputs, grit.node.empty.OutputsNode)) | 208 isinstance(outputs, grit.node.empty.OutputsNode)) |
| 209 | 209 |
| 210 if self.header_dir: | 210 if self.header_dir: |
| 211 cpp_header = self.__CreateCppHeaderOutputNode(outputs, self.header_dir) | 211 cpp_header = self.__CreateCppHeaderOutputNode(outputs, self.header_dir) |
| 212 for lang in self.languages: | 212 for lang in self.languages: |
| 213 # Create an output element for each language. | 213 # Create an output element for each language. |
| 214 if self.rc_dir: | 214 if self.rc_dir: |
| 215 self.__CreateRcOutputNode(outputs, lang, self.rc_dir) | 215 self.__CreateRcOutputNode(outputs, lang, self.rc_dir) |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 A <string> element is by default translatable unless otherwise marked. | 490 A <string> element is by default translatable unless otherwise marked. |
| 491 """ | 491 """ |
| 492 if android_string.hasAttribute('translatable'): | 492 if android_string.hasAttribute('translatable'): |
| 493 value = android_string.getAttribute('translatable').lower() | 493 value = android_string.getAttribute('translatable').lower() |
| 494 if value not in ('true', 'false'): | 494 if value not in ('true', 'false'): |
| 495 print 'Warning: translatable attribute has invalid value: %s' % value | 495 print 'Warning: translatable attribute has invalid value: %s' % value |
| 496 return value == 'true' | 496 return value == 'true' |
| 497 else: | 497 else: |
| 498 return True | 498 return True |
| 499 | 499 |
| OLD | NEW |