diff options
author | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-02 03:34:35 +0000 |
---|---|---|
committer | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-02 03:34:35 +0000 |
commit | 63e96497767c184c4026be3850bb1ff59223f87b (patch) | |
tree | daae0f1ae219829ae4edd08ed3d60b5be10cf2ff /remoting/tools | |
parent | 5abfa4f0bd434526663b4ff776698069a1f3a8da (diff) | |
download | chromium_src-63e96497767c184c4026be3850bb1ff59223f87b.zip chromium_src-63e96497767c184c4026be3850bb1ff59223f87b.tar.gz chromium_src-63e96497767c184c4026be3850bb1ff59223f87b.tar.bz2 |
Revert 165605 - Fix branding in chromoting string resources.
When chromoting resources were converted from messages.json to .grd format
incorrect branding was used. Beside that simplified how resources are
generated:
1. Now <if> is used to handle branded strings instead of generating grd file in build time
2. Removed resource_ids - ids are now specified in grd files.
BUG=158995
Review URL: https://chromiumcodereview.appspot.com/11275101
TBR=sergeyu@chromium.org
Review URL: https://codereview.chromium.org/11359035
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165611 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/tools')
-rwxr-xr-x | remoting/tools/remove_official_branding.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/remoting/tools/remove_official_branding.py b/remoting/tools/remove_official_branding.py new file mode 100755 index 0000000..9d9d4cb --- /dev/null +++ b/remoting/tools/remove_official_branding.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python +# Copyright (c) 2012 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Replaces "Chrome Remote Desktop" with "Chromoting" in GRD files""" + +import sys +from optparse import OptionParser +import xml.dom.minidom as minidom + +def update_xml_node(element): + for child in element.childNodes: + if child.nodeType == minidom.Node.ELEMENT_NODE: + update_xml_node(child) + elif child.nodeType == minidom.Node.TEXT_NODE: + child.replaceWholeText( + child.data.replace("Chrome Remote Desktop", "Chromoting")) + +def remove_official_branding(input_file, output_file): + xml = minidom.parse(input_file) + + # Remove all translations. + for translations in xml.getElementsByTagName("translations"): + for translation in translations.getElementsByTagName("file"): + translations.removeChild(translation) + + for outputs in xml.getElementsByTagName("outputs"): + for output in outputs.getElementsByTagName("output"): + lang = output.getAttribute("lang") + if lang and lang != "en": + outputs.removeChild(output) + + # Update branding. + update_xml_node(xml) + + out = file(output_file, "w") + out.write(xml.toxml(encoding = "UTF-8")) + out.close() + +def main(): + usage = 'Usage: remove_official_branding <input.grd> <output.grd>' + parser = OptionParser(usage=usage) + options, args = parser.parse_args() + if len(args) != 2: + parser.error('two positional arguments expected') + + return remove_official_branding(args[0], args[1]) + +if __name__ == '__main__': + sys.exit(main()) + |