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

Side by Side Diff: ui/base/l10n/l10n_util.cc

Issue 10270023: Add new ResourceBundle::Delegate interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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
« no previous file with comments | « ui/aura/test/test_suite.cc ('k') | ui/base/resource/resource_bundle.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "ui/base/l10n/l10n_util.h" 5 #include "ui/base/l10n/l10n_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstdlib> 8 #include <cstdlib>
9 #include <iterator> 9 #include <iterator>
10 #include <string> 10 #include <string>
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 return false; 233 return false;
234 234
235 // IsLocalePartiallyPopulated() can be called here for an early return w/o 235 // IsLocalePartiallyPopulated() can be called here for an early return w/o
236 // checking the resource availability below. It'd help when Chrome is run 236 // checking the resource availability below. It'd help when Chrome is run
237 // under a system locale Chrome is not localized to (e.g.Farsi on Linux), 237 // under a system locale Chrome is not localized to (e.g.Farsi on Linux),
238 // but it'd slow down the start up time a little bit for locales Chrome is 238 // but it'd slow down the start up time a little bit for locales Chrome is
239 // localized to. So, we don't call it here. 239 // localized to. So, we don't call it here.
240 if (!l10n_util::IsLocaleSupportedByOS(locale)) 240 if (!l10n_util::IsLocaleSupportedByOS(locale))
241 return false; 241 return false;
242 242
243 return ResourceBundle::LocaleDataPakExists(locale); 243 return ResourceBundle::GetSharedInstance().LocaleDataPakExists(locale);
244 } 244 }
245 245
246 bool CheckAndResolveLocale(const std::string& locale, 246 bool CheckAndResolveLocale(const std::string& locale,
247 std::string* resolved_locale) { 247 std::string* resolved_locale) {
248 if (IsLocaleAvailable(locale)) { 248 if (IsLocaleAvailable(locale)) {
249 *resolved_locale = locale; 249 *resolved_locale = locale;
250 return true; 250 return true;
251 } 251 }
252 252
253 // If there's a variant, skip over it so we can try without the region 253 // If there's a variant, skip over it so we can try without the region
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 } 439 }
440 } 440 }
441 441
442 // Fallback on en-US. 442 // Fallback on en-US.
443 const std::string fallback_locale("en-US"); 443 const std::string fallback_locale("en-US");
444 if (IsLocaleAvailable(fallback_locale)) { 444 if (IsLocaleAvailable(fallback_locale)) {
445 base::i18n::SetICUDefaultLocale(fallback_locale); 445 base::i18n::SetICUDefaultLocale(fallback_locale);
446 return fallback_locale; 446 return fallback_locale;
447 } 447 }
448 448
449 // No locale data file was found; we shouldn't get here.
450 NOTREACHED();
451
452 return std::string(); 449 return std::string();
453 450
454 #endif 451 #endif
455 } 452 }
456 453
457 string16 GetDisplayNameForLocale(const std::string& locale, 454 string16 GetDisplayNameForLocale(const std::string& locale,
458 const std::string& display_locale, 455 const std::string& display_locale,
459 bool is_for_ui) { 456 bool is_for_ui) {
460 std::string locale_code = locale; 457 std::string locale_code = locale;
461 // Internally, we use the language code of zh-CN and zh-TW, but we want the 458 // Internally, we use the language code of zh-CN and zh-TW, but we want the
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 for (size_t i = 0; i < arraysize(kAcceptLanguageList); ++i) { 817 for (size_t i = 0; i < arraysize(kAcceptLanguageList); ++i) {
821 if (!IsLocaleNameTranslated(kAcceptLanguageList[i], display_locale)) 818 if (!IsLocaleNameTranslated(kAcceptLanguageList[i], display_locale))
822 // TODO(jungshik) : Put them at the of the list with language codes 819 // TODO(jungshik) : Put them at the of the list with language codes
823 // enclosed by brackets instead of skipping. 820 // enclosed by brackets instead of skipping.
824 continue; 821 continue;
825 locale_codes->push_back(kAcceptLanguageList[i]); 822 locale_codes->push_back(kAcceptLanguageList[i]);
826 } 823 }
827 } 824 }
828 825
829 } // namespace l10n_util 826 } // namespace l10n_util
OLDNEW
« no previous file with comments | « ui/aura/test/test_suite.cc ('k') | ui/base/resource/resource_bundle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698