summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorthomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-31 14:38:40 +0000
committerthomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-31 14:38:40 +0000
commit04908d81da1f1a744ff970788542339fcff8a40a (patch)
tree61a99e5442647e3f0b5d0fea27970e10c6eebb19 /app
parent93765934392b698183ff0242b302c062bb53fa4e (diff)
downloadchromium_src-04908d81da1f1a744ff970788542339fcff8a40a.zip
chromium_src-04908d81da1f1a744ff970788542339fcff8a40a.tar.gz
chromium_src-04908d81da1f1a744ff970788542339fcff8a40a.tar.bz2
[Mac] honor the locale passed for loading the pak file.
chrome_dll_main has SubprocessNeedsResourceBundle(), that is what prompted this. Map the request locale into a Mac on disk localization and ask NSBundle to fetch that specific localization. This lets the language come over via the command line argument and then be honored in the helper processes. TEST=the ui_tests stop logging a message about ignoring locale for the NSBundle one. BUG=none Review URL: http://codereview.chromium.org/503089 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35420 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app')
-rw-r--r--app/resource_bundle_mac.mm35
1 files changed, 28 insertions, 7 deletions
diff --git a/app/resource_bundle_mac.mm b/app/resource_bundle_mac.mm
index 9d14440..1388932 100644
--- a/app/resource_bundle_mac.mm
+++ b/app/resource_bundle_mac.mm
@@ -9,13 +9,26 @@
#include "base/file_path.h"
#include "base/logging.h"
#include "base/mac_util.h"
+#include "base/sys_string_conversions.h"
#include "skia/ext/skia_utils_mac.h"
namespace {
-FilePath GetResourcesPakFilePath(NSString* name) {
- NSString *resource_path = [mac_util::MainAppBundle() pathForResource:name
- ofType:@"pak"];
+FilePath GetResourcesPakFilePath(NSString* name, NSString* mac_locale) {
+ NSString *resource_path;
+ // Some of the helper processes need to be able to fetch resources
+ // (chrome_dll_main.cc SubprocessNeedsResourceBundle()). Fetch the same locale
+ // as the already-running browser instead of using what NSBundle might pick
+ // based on values at helper launch time.
+ if ([mac_locale length]) {
+ resource_path = [mac_util::MainAppBundle() pathForResource:name
+ ofType:@"pak"
+ inDirectory:@""
+ forLocalization:mac_locale];
+ } else {
+ resource_path = [mac_util::MainAppBundle() pathForResource:name
+ ofType:@"pak"];
+ }
if (!resource_path)
return FilePath();
return FilePath([resource_path fileSystemRepresentation]);
@@ -25,14 +38,22 @@ FilePath GetResourcesPakFilePath(NSString* name) {
// static
FilePath ResourceBundle::GetResourcesFilePath() {
- return GetResourcesPakFilePath(@"chrome");
+ return GetResourcesPakFilePath(@"chrome", nil);
}
// static
FilePath ResourceBundle::GetLocaleFilePath(const std::string& app_locale) {
- DLOG_IF(WARNING, !app_locale.empty())
- << "ignoring requested locale in favor of NSBundle's selection";
- return GetResourcesPakFilePath(@"locale");
+ NSString* mac_locale = base::SysUTF8ToNSString(app_locale);
+
+ // Mac OS X uses "_" instead of "-", so swap to get a Mac-style value.
+ mac_locale = [mac_locale stringByReplacingOccurrencesOfString:@"-"
+ withString:@"_"];
+
+ // On disk, the "en_US" resources are just "en" (http://crbug.com/25578).
+ if ([mac_locale isEqual:@"en_US"])
+ mac_locale = @"en";
+
+ return GetResourcesPakFilePath(@"locale", mac_locale);
}
NSImage* ResourceBundle::GetNSImageNamed(int resource_id) {