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

Side by Side Diff: remoting/tools/remove_official_branding.py

Issue 11150008: Move Chromoting strings to string_resources.grd. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 | « remoting/tools/json_to_grd.py ('k') | remoting/webapp/_locales.official/ar/messages.json » ('j') | 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 """Replaces "Chrome Remote Desktop" with "Chromoting" in GRD files""" 6 """Replaces "Chrome Remote Desktop" with "Chromoting" in GRD files"""
7 7
8 import sys 8 import sys
9 from optparse import OptionParser 9 from optparse import OptionParser
10 import xml.dom.minidom as minidom 10 import xml.dom.minidom as minidom
11 11
12 def update_xml_node(element): 12 def update_xml_node(element):
13 for child in element.childNodes: 13 for child in element.childNodes:
14 if child.nodeType == minidom.Node.ELEMENT_NODE: 14 if child.nodeType == minidom.Node.ELEMENT_NODE:
15 update_xml_node(child) 15 update_xml_node(child)
16 elif child.nodeType == minidom.Node.TEXT_NODE: 16 elif child.nodeType == minidom.Node.TEXT_NODE:
17 child.replaceWholeText( 17 child.replaceWholeText(
18 child.data.replace("Chrome Remote Desktop", "Chromoting")) 18 child.data.replace("Chrome Remote Desktop", "Chromoting"))
19 19
20 def remove_official_branding(input, output): 20 def remove_official_branding(input_file, output_file):
21 xml = minidom.parse(input) 21 xml = minidom.parse(input_file)
22 22
23 # Remove all translations. 23 # Remove all translations.
24 for translations in xml.getElementsByTagName("translations"): 24 for translations in xml.getElementsByTagName("translations"):
25 for translation in xml.getElementsByTagName("translation"): 25 for translation in translations.getElementsByTagName("file"):
26 translations.removeChild(translation) 26 translations.removeChild(translation)
27 27
28 for outputs in xml.getElementsByTagName("outputs"):
29 for output in outputs.getElementsByTagName("output"):
30 lang = output.getAttribute("lang")
31 if lang and lang != "en":
32 outputs.removeChild(output)
33
28 # Update branding. 34 # Update branding.
29 update_xml_node(xml) 35 update_xml_node(xml)
30 36
31 out = file(output, "w") 37 out = file(output_file, "w")
32 out.write(xml.toxml(encoding = "UTF-8")) 38 out.write(xml.toxml(encoding = "UTF-8"))
33 out.close() 39 out.close()
34 40
35 def main(): 41 def main():
36 usage = 'Usage: remove_official_branding <input.grd> <output.grd>' 42 usage = 'Usage: remove_official_branding <input.grd> <output.grd>'
37 parser = OptionParser(usage=usage) 43 parser = OptionParser(usage=usage)
38 options, args = parser.parse_args() 44 options, args = parser.parse_args()
39 if len(args) != 2: 45 if len(args) != 2:
40 parser.error('two positional arguments expected') 46 parser.error('two positional arguments expected')
41 47
42 return remove_official_branding(args[0], args[1]) 48 return remove_official_branding(args[0], args[1])
43 49
44 if __name__ == '__main__': 50 if __name__ == '__main__':
45 sys.exit(main()) 51 sys.exit(main())
46 52
OLDNEW
« no previous file with comments | « remoting/tools/json_to_grd.py ('k') | remoting/webapp/_locales.official/ar/messages.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698