diff options
author | alexeypa@google.com <alexeypa@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-30 18:43:25 +0000 |
---|---|---|
committer | alexeypa@google.com <alexeypa@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-30 18:43:25 +0000 |
commit | ae7f7846ea0d236b69e612bbf9abcedb23b2bf31 (patch) | |
tree | 62cd007732159b32d226cc35b4d69b2464e61737 /remoting/tools | |
parent | 0a8228ddf581cba21f41979059cf8b0a2af75386 (diff) | |
download | chromium_src-ae7f7846ea0d236b69e612bbf9abcedb23b2bf31.zip chromium_src-ae7f7846ea0d236b69e612bbf9abcedb23b2bf31.tar.gz chromium_src-ae7f7846ea0d236b69e612bbf9abcedb23b2bf31.tar.bz2 |
Revert 214379 "Localized Chromoting Host on Mac and Linux."
The CL broke "Google Chrome Win" in a strange way:
http://build.chromium.org/p/chromium.chrome/builders/Google%20Chrome%20Win/builds/19799/steps/compile/logs/stdio
671> Traceback (most recent call last):
671> File "webapp/build-webapp.py", line 331, in <module>
671> sys.exit(main())
671> File "webapp/build-webapp.py", line 327, in main
671> sys.argv[5], sys.argv[6], files, locales, patches)
671> File "webapp/build-webapp.py", line 141, in buildWebApp
671> shutil.copy2(current_locale, destination_file)
671> File "c:\b\build\slave\google-chrome-rel-win\build\src\third_party\python_26\lib\shutil.py", line 99, in copy2
671> copyfile(src, dst)
671> File "c:\b\build\slave\google-chrome-rel-win\build\src\third_party\python_26\lib\shutil.py", line 52, in copyfile
671> fsrc = open(src, 'rb')
671> IOError: [Errno 2] No such file or directory: 'c:/b/build/slave/google-chrome-rel-win/build/src/build/Release/\\remoting_ocales\\nl.pak'
671>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(151,5): error MSB6006: "cmd.exe" exited with code 1.
> Localized Chromoting Host on Mac and Linux.
>
> Re-landing r213997. TBR because this is a trivial, mechanical fix.
>
> This CL implements generation of localizable strings from remoting_strings.grd file. Depending on the platform the localized resources are placed to:
> - Mac: localized .string and .pak resources are added to each application bundle under 'Resources/<locale>.lproj'
> - Linux: localized .pak files are placed under 'remoting_locales' directory next to the binary locading them.
> - Windows: .rc resources are generated from .jinja2 templates and embedded into a relevant binary.
>
> Chrome l10n and i18n APIs are used to retrieve the current locale and RTL flag (Mac & Linux). The it2me plugin sets the locale to match the locale of the browser.
>
> Collateral changes:
> - UiString is not used any more.
> - Increased width of disconnect window message on Mac.
> - The host plugin version is correctly reported on Mac.
> - Dialogs use RTL templates in case of RTL languages. No more updating the templates dynamically (Windows).
> - remoting_unittests.ResourcesTest now runs on Mac, LInux and Windows.
> - '@' is used for variable substitutions by remoting_localize.py.
> - HOST_PLUGIN_MIME_TYPE is defined in one place now.
> - Deleted unused commong_resources.grd.
>
> Mac installer and preference panel are not localized yet.
>
> TBR=garykac@chromium.org
> BUG=155204
>
> Review URL: https://codereview.chromium.org/20985002
TBR=alexeypa@chromium.org
Review URL: https://codereview.chromium.org/21090006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214401 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/tools')
-rwxr-xr-x | remoting/tools/build/remoting_copy_locales.py | 160 | ||||
-rwxr-xr-x | remoting/tools/build/remoting_localize.py | 14 | ||||
-rwxr-xr-x | remoting/tools/verify_resources.py | 4 |
3 files changed, 4 insertions, 174 deletions
diff --git a/remoting/tools/build/remoting_copy_locales.py b/remoting/tools/build/remoting_copy_locales.py deleted file mode 100755 index 4d1d41a..0000000 --- a/remoting/tools/build/remoting_copy_locales.py +++ /dev/null @@ -1,160 +0,0 @@ -#!/usr/bin/env python -# Copyright 2013 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. - -"""Helper script to repack paks for a list of locales. - -Gyp doesn't have any built-in looping capability, so this just provides a way to -loop over a list of locales when repacking pak files, thus avoiding a -proliferation of mostly duplicate, cut-n-paste gyp actions. -""" - -import optparse -import os -import sys - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', '..', - 'tools', 'grit')) -from grit.format import data_pack - -# Some build paths defined by gyp. -GRIT_DIR = None -INT_DIR = None - -# The target platform. If it is not defined, sys.platform will be used. -OS = None - -# Extra input files. -EXTRA_INPUT_FILES = [] - -class Usage(Exception): - def __init__(self, msg): - self.msg = msg - - -def calc_output(locale): - """Determine the file that will be generated for the given locale.""" - #e.g. '<(INTERMEDIATE_DIR)/remoting_locales/da.pak', - if OS == 'mac' or OS == 'ios': - # For Cocoa to find the locale at runtime, it needs to use '_' instead - # of '-' (http://crbug.com/20441). - return os.path.join(INT_DIR, 'remoting', 'resources', - '%s.lproj' % locale.replace('-', '_'), 'locale.pak') - else: - return os.path.join(INT_DIR, 'remoting_locales', locale + '.pak') - - -def calc_inputs(locale): - """Determine the files that need processing for the given locale.""" - inputs = [] - - #e.g. '<(grit_out_dir)/remoting/resources/da.pak' - inputs.append(os.path.join(GRIT_DIR, 'remoting/resources/%s.pak' % locale)) - - # Add any extra input files. - for extra_file in EXTRA_INPUT_FILES: - inputs.append('%s_%s.pak' % (extra_file, locale)) - - return inputs - - -def list_outputs(locales): - """Returns the names of files that will be generated for the given locales. - - This is to provide gyp the list of output files, so build targets can - properly track what needs to be built. - """ - outputs = [] - for locale in locales: - outputs.append(calc_output(locale)) - # Quote each element so filename spaces don't mess up gyp's attempt to parse - # it into a list. - return " ".join(['"%s"' % x for x in outputs]) - - -def list_inputs(locales): - """Returns the names of files that will be processed for the given locales. - - This is to provide gyp the list of input files, so build targets can properly - track their prerequisites. - """ - inputs = [] - for locale in locales: - inputs += calc_inputs(locale) - # Quote each element so filename spaces don't mess up gyp's attempt to parse - # it into a list. - return " ".join(['"%s"' % x for x in inputs]) - - -def repack_locales(locales): - """ Loop over and repack the given locales.""" - for locale in locales: - inputs = calc_inputs(locale) - output = calc_output(locale) - data_pack.DataPack.RePack(output, inputs) - - -def DoMain(argv): - global GRIT_DIR - global INT_DIR - global OS - global EXTRA_INPUT_FILES - - parser = optparse.OptionParser("usage: %prog [options] locales") - parser.add_option("-i", action="store_true", dest="inputs", default=False, - help="Print the expected input file list, then exit.") - parser.add_option("-o", action="store_true", dest="outputs", default=False, - help="Print the expected output file list, then exit.") - parser.add_option("-g", action="store", dest="grit_dir", - help="GRIT build files output directory.") - parser.add_option("-x", action="store", dest="int_dir", - help="Intermediate build files output directory.") - parser.add_option("-e", action="append", dest="extra_input", default=[], - help="Full path to an extra input pak file without the\ - locale suffix and \".pak\" extension.") - parser.add_option("-p", action="store", dest="os", - help="The target OS. (e.g. mac, linux, win, etc.)") - options, locales = parser.parse_args(argv) - - if not locales: - parser.error('Please specificy at least one locale to process.\n') - - print_inputs = options.inputs - print_outputs = options.outputs - GRIT_DIR = options.grit_dir - INT_DIR = options.int_dir - EXTRA_INPUT_FILES = options.extra_input - OS = options.os - - if not OS: - if sys.platform == 'darwin': - OS = 'mac' - elif sys.platform.startswith('linux'): - OS = 'linux' - elif sys.platform in ('cygwin', 'win32'): - OS = 'win' - else: - OS = sys.platform - - if print_inputs and print_outputs: - parser.error('Please specify only one of "-i" or "-o".\n') - if print_inputs and not GRIT_DIR: - parser.error('Please specify "-g".\n') - if print_outputs and not INT_DIR: - parser.error('Please specify "-x".\n') - if not (print_inputs or print_outputs or (GRIT_DIR and INT_DIR)): - parser.error('Please specify both "-g" and "-x".\n') - - if print_inputs: - return list_inputs(locales) - - if print_outputs: - return list_outputs(locales) - - return repack_locales(locales) - -if __name__ == '__main__': - results = DoMain(sys.argv[1:]) - if results: - print results diff --git a/remoting/tools/build/remoting_localize.py b/remoting/tools/build/remoting_localize.py index 6a88884..8dc0538 100755 --- a/remoting/tools/build/remoting_localize.py +++ b/remoting/tools/build/remoting_localize.py @@ -542,10 +542,7 @@ def IsRtlLanguage(language): def NormalizeLanguageCode(language): - lang = language.replace('_', '-', 1) - if lang == 'en-US': - lang = 'en' - return lang + return language.replace('_', '-', 1) def GetDataPackageSuffix(language): @@ -642,12 +639,6 @@ class MessageMap: return lambda message: self.GetText(message) -# Use '@' as a delimiter for string templates instead of '$' to avoid unintended -# expansion when passing the string from GYP. -class GypTemplate(Template): - delimiter = '@' - - def Localize(source, locales, options): # Set the list of languages to use. languages = map(NormalizeLanguageCode, locales) @@ -710,13 +701,12 @@ def Localize(source, locales, options): # Generate a separate file per each locale if requested. outputs = [] if options.locale_output: - target = GypTemplate(options.locale_output) + target = Template(options.locale_output) for lang in languages: context['languages'] = [ lang ] context['language'] = lang context['pak_suffix'] = GetDataPackageSuffix(lang) context['json_suffix'] = GetJsonSuffix(lang) - message_map.SelectLanguage(lang) template_file_name = target.safe_substitute(context) outputs.append(template_file_name) diff --git a/remoting/tools/verify_resources.py b/remoting/tools/verify_resources.py index eb59b2f..4ffd494 100755 --- a/remoting/tools/verify_resources.py +++ b/remoting/tools/verify_resources.py @@ -62,7 +62,7 @@ def ExtractTagFromLine(file_type, line): # Javascript style m = re.search('/\*i18n-content\*/[\'"]([^\`"]*)[\'"]', line) if m: return m.group(1) - elif file_type == 'cc' or file_type == 'mm': + elif file_type == 'cc': # C++ style m = re.search('IDR_([A-Z0-9_]*)', line) if m: return m.group(1) @@ -89,7 +89,7 @@ def VerifyFile(filename, messages, used_tags): base_name, extension = os.path.splitext(filename) extension = extension[1:] - if extension not in ['js', 'cc', 'html', 'json', 'jinja2', 'mm']: + if extension not in ['js', 'cc', 'html', 'json', 'jinja2']: raise Exception("Unknown file type: %s" % extension) result = True |