diff options
author | thomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-02 21:31:57 +0000 |
---|---|---|
committer | thomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-02 21:31:57 +0000 |
commit | 464dca7a6ff0f7649ec54fcac964306d07499c30 (patch) | |
tree | 4dff0db9ea97395c0e0db6a594f2c5ddf08ae5f2 | |
parent | e984058bf2de1d110a3ecca1c9b6a77e3f297704 (diff) | |
download | chromium_src-464dca7a6ff0f7649ec54fcac964306d07499c30.zip chromium_src-464dca7a6ff0f7649ec54fcac964306d07499c30.tar.gz chromium_src-464dca7a6ff0f7649ec54fcac964306d07499c30.tar.bz2 |
Even though the Finder's Get Info shows the language correctly when you use lproj folders with '-' instead of '_', Cocoa fails to load things at runtime from within them.
Map the names when writing lproj folders to use underscore.
Put an option on the helper script to control dash/underscore mapping since we need support for both.
TEST=try chinese and traditional chinese, they work now.
BUG=20441
Review URL: http://codereview.chromium.org/187011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25243 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-x | chrome/app/tweak_mac_lproj_folders | 15 | ||||
-rw-r--r-- | chrome/chrome.gyp | 6 | ||||
-rwxr-xr-x | chrome/tools/build/apply_locales.py | 20 | ||||
-rwxr-xr-x | chrome/tools/build/repack_locales.py | 4 | ||||
-rw-r--r-- | chrome/tools/mac_helpers/infoplist_strings_util.mm | 8 |
5 files changed, 40 insertions, 13 deletions
diff --git a/chrome/app/tweak_mac_lproj_folders b/chrome/app/tweak_mac_lproj_folders index 78dba5b..9659e67 100755 --- a/chrome/app/tweak_mac_lproj_folders +++ b/chrome/app/tweak_mac_lproj_folders @@ -17,17 +17,22 @@ cd "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/Contents/Resources" # TODO: This can go away about 09/01/09, when they won't exist on the bots or # developers' local builds. rm -rf "zh.lproj" "en.lproj" +# Remove the invalid dirs with - instead of _ (http://crbug.com/20441) +# TODO: This can go away about 09/09/09, when they won't exist on the bots or +# developers' local builds. +rm -rf "en-GB.lproj" "en-US.lproj" "es-419.lproj" "pt-BR.lproj" "pt-PT.lproj" \ + "zh-CN.lproj" "zh-TW.lproj" -# Provide an link for en.lproj that points to en-US.lproj. +# Provide an link for en.lproj that points to en_US.lproj. # The standard OS language list includes English (en) and not a specific -# "flavor" such as U.S. English (en-US). When checking for a language match, +# "flavor" such as U.S. English (en_US). When checking for a language match, # the OS will remove subtags if no exact match is found, so that en will be # used if the user's preferred language list only contains British English -# (en-GB) and no specific en-GB translation is available. +# (en_GB) and no specific en_GB translation is available. # # To ensure that users with the default language list, which contains English # without any regional subtag, as well as users with a specific variant of # English with a regional subtag, will have access to an English-localized -# application, a symbolic link from en.lproj to en-US.lproj is provided. -ln -fhs "en-US.lproj" "en.lproj" +# application, a symbolic link from en.lproj to en_US.lproj is provided. +ln -fhs "en_US.lproj" "en.lproj" diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 68fd197..56b4a71 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -24,6 +24,8 @@ 'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/chrome', # TODO(mmoss) This might need to go somewhere more general, then we can use # it to also rewrite app/locales/locales.gyp with a helper script. + # NOTE: When these end up in the Mac bundle, we need to replace '-' for '_' + # so Cocoa is happy (http://crbug.com/20441). 'locales': [ 'ar', 'bg', 'bn', 'ca', 'cs', 'da', 'de', 'el', 'en-GB', 'en-US', 'es-419', 'es', 'et', 'fi', 'fil', 'fr', 'gu', 'he', @@ -3270,7 +3272,7 @@ ], 'outputs': [ # TODO: remove this helper when we have loops in GYP - '>!@(<(apply_locales_cmd) \'<(output_path)/ZZLOCALE.lproj/InfoPlist.strings\' <(locales))', + '>!@(<(apply_locales_cmd) -d \'<(output_path)/ZZLOCALE.lproj/InfoPlist.strings\' <(locales))', ], 'action': [ '<(tool_path)', @@ -4900,7 +4902,7 @@ ], 'outputs': [ # TODO: remove this helper when we have loops in GYP - '>!@(<(apply_locales_cmd) \'<(output_path)/ZZLOCALE.lproj/InfoPlist.strings\' <(locales))', + '>!@(<(apply_locales_cmd) -d \'<(output_path)/ZZLOCALE.lproj/InfoPlist.strings\' <(locales))', ], 'action': [ '<(tool_path)', diff --git a/chrome/tools/build/apply_locales.py b/chrome/tools/build/apply_locales.py index c7b0861..fc8c4af 100755 --- a/chrome/tools/build/apply_locales.py +++ b/chrome/tools/build/apply_locales.py @@ -6,17 +6,31 @@ # TODO: remove this script when GYP has for loops import sys +import optparse def main(argv): - if len(argv) < 3: + + parser = optparse.OptionParser() + usage = 'usage: %s [options ...] format_string locale_list' + parser.set_usage(usage.replace('%s', '%prog')) + parser.add_option('-d', dest='dash_to_underscore', action="store_true", + default=False, help='map "-" to "_" in locales') + + (options, arglist) = parser.parse_args(argv) + + if len(arglist) < 3: print 'ERROR: need string and list of locales' return 1 - str_template = argv[1] - locales = argv[2:] + str_template = arglist[1] + locales = arglist[2:] results = [] for locale in locales: + # For Cocoa to find the locale at runtime, it needs to use '_' instead + # of '-'. (http://crbug.com/20441) + if options.dash_to_underscore: + locale = locale.replace('-', '_') results.append(str_template.replace('ZZLOCALE', locale)) # Quote each element so filename spaces don't mess up GYP's attempt to parse diff --git a/chrome/tools/build/repack_locales.py b/chrome/tools/build/repack_locales.py index 7e05e81..fc55b2d 100755 --- a/chrome/tools/build/repack_locales.py +++ b/chrome/tools/build/repack_locales.py @@ -36,7 +36,9 @@ def calc_output(locale): """Determine the file that will be generated for the given locale.""" #e.g. '<(INTERMEDIATE_DIR)/repack/da.pak', if sys.platform in ('darwin',): - return '%s/repack/%s.lproj/locale.pak' % (INT_DIR, locale) + # For Cocoa to find the locale at runtime, it needs to use '_' instead + # of '-'. (http://crbug.com/20441) + return '%s/repack/%s.lproj/locale.pak' % (INT_DIR, locale.replace('-', '_')) else: return '%s/repack/%s.pak' % (INT_DIR, locale) diff --git a/chrome/tools/mac_helpers/infoplist_strings_util.mm b/chrome/tools/mac_helpers/infoplist_strings_util.mm index 70fbca6..f2bbf7a 100644 --- a/chrome/tools/mac_helpers/infoplist_strings_util.mm +++ b/chrome/tools/mac_helpers/infoplist_strings_util.mm @@ -267,10 +267,14 @@ int main(int argc, char* const argv[]) { } // Make sure the lproj we write to exists + NSString *lproj_name = [NSString stringWithFormat:@"%s.lproj", cur_lang]; + // For Cocoa to find the locale at runtime, it needs to use '_' instead of + // '-'. (http://crbug.com/20441) + lproj_name = [lproj_name stringByReplacingOccurrencesOfString:@"-" + withString:@"_"]; NSString *output_path = [[NSString stringWithUTF8String:output_dir] - stringByAppendingPathComponent: - [NSString stringWithFormat:@"%s.lproj", cur_lang]]; + stringByAppendingPathComponent:lproj_name]; NSError* error = nil; if (![fm fileExistsAtPath:output_path] && ![fm createDirectoryAtPath:output_path |