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

Side by Side Diff: ui/base/l10n/l10n_util_mac.mm

Issue 9240004: Transition to base/mac/bundle_locations.h step 3 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 11 months 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import <Foundation/Foundation.h> 5 #import <Foundation/Foundation.h>
6 6
7 #include "base/sys_string_conversions.h" 7 #include "base/sys_string_conversions.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/bundle_locations.h"
10 #include "ui/base/l10n/l10n_util.h" 11 #include "ui/base/l10n/l10n_util.h"
11 #include "ui/base/l10n/l10n_util_mac.h" 12 #include "ui/base/l10n/l10n_util_mac.h"
12 13
13 namespace { 14 namespace {
14 15
15 class OverrideLocaleHolder { 16 class OverrideLocaleHolder {
16 public: 17 public:
17 OverrideLocaleHolder() {} 18 OverrideLocaleHolder() {}
18 const std::string& value() const { return value_; } 19 const std::string& value() const { return value_; }
19 void set_value(const std::string override_value) { value_ = override_value; } 20 void set_value(const std::string override_value) { value_ = override_value; }
(...skipping 17 matching lines...) Expand all
37 // NSBundle really should only be called on the main thread. 38 // NSBundle really should only be called on the main thread.
38 DCHECK([NSThread isMainThread]); 39 DCHECK([NSThread isMainThread]);
39 40
40 // Chrome really only has one concept of locale, but Mac OS X has locale and 41 // Chrome really only has one concept of locale, but Mac OS X has locale and
41 // language that can be set independently. After talking with Chrome UX folks 42 // language that can be set independently. After talking with Chrome UX folks
42 // (Cole), the best path from an experience point of view is to map the Mac OS 43 // (Cole), the best path from an experience point of view is to map the Mac OS
43 // X language into the Chrome locale. This way strings like "Yesterday" and 44 // X language into the Chrome locale. This way strings like "Yesterday" and
44 // "Today" are in the same language as raw dates like "March 20, 1999" (Chrome 45 // "Today" are in the same language as raw dates like "March 20, 1999" (Chrome
45 // strings resources vs ICU generated strings). This also makes the Mac acts 46 // strings resources vs ICU generated strings). This also makes the Mac acts
46 // like other Chrome platforms. 47 // like other Chrome platforms.
47 NSArray* languageList = [[NSBundle mainBundle] preferredLocalizations]; 48 NSArray* languageList = [base::mac::OuterBundle() preferredLocalizations];
48 NSString* firstLocale = [languageList objectAtIndex:0]; 49 NSString* firstLocale = [languageList objectAtIndex:0];
49 // Mac OS X uses "_" instead of "-", so swap to get a real locale value. 50 // Mac OS X uses "_" instead of "-", so swap to get a real locale value.
50 std::string locale_value = 51 std::string locale_value =
51 [[firstLocale stringByReplacingOccurrencesOfString:@"_" 52 [[firstLocale stringByReplacingOccurrencesOfString:@"_"
52 withString:@"-"] UTF8String]; 53 withString:@"-"] UTF8String];
53 54
54 // On disk the "en-US" resources are just "en" (http://crbug.com/25578), so 55 // On disk the "en-US" resources are just "en" (http://crbug.com/25578), so
55 // the reverse mapping is done here to continue to feed Chrome the same values 56 // the reverse mapping is done here to continue to feed Chrome the same values
56 // in all cases on all platforms. (l10n_util maps en to en-US if it gets 57 // in all cases on all platforms. (l10n_util maps en to en-US if it gets
57 // passed this on the command line) 58 // passed this on the command line)
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 const string16& a, 164 const string16& a,
164 const string16& b, 165 const string16& b,
165 const string16& c, 166 const string16& c,
166 const string16& d) { 167 const string16& d) {
167 return FixUpWindowsStyleLabel(l10n_util::GetStringFUTF16(message_id, 168 return FixUpWindowsStyleLabel(l10n_util::GetStringFUTF16(message_id,
168 a, b, c, d)); 169 a, b, c, d));
169 } 170 }
170 171
171 172
172 } // namespace l10n_util 173 } // namespace l10n_util
OLDNEW
« chrome/browser/shell_integration_mac.mm ('K') | « chrome/common/chrome_version_info_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698