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

Side by Side Diff: grit/tool/android2grd.py

Issue 125523002: android2grd tool now puts <outputs> element first. (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk
Patch Set: Created 6 years, 11 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/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
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
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
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