OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util.h" | 5 #include "app/l10n_util.h" |
6 | 6 |
7 #include <cstdlib> | 7 #include <cstdlib> |
8 | 8 |
9 #include "app/app_paths.h" | 9 #include "app/app_paths.h" |
10 #include "app/l10n_util_collator.h" | 10 #include "app/l10n_util_collator.h" |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 // lanaguage name). These locales have to be distinguished from the | 220 // lanaguage name). These locales have to be distinguished from the |
221 // fully populated locales to which Chrome is localized. | 221 // fully populated locales to which Chrome is localized. |
222 bool IsLocalePartiallyPopulated(const std::string& locale_name) { | 222 bool IsLocalePartiallyPopulated(const std::string& locale_name) { |
223 // For partially populated locales, even the translation for "English" | 223 // For partially populated locales, even the translation for "English" |
224 // is not available. A more robust/elegant way to check is to add a special | 224 // is not available. A more robust/elegant way to check is to add a special |
225 // field (say, 'isPartial' to our version of ICU locale files) and | 225 // field (say, 'isPartial' to our version of ICU locale files) and |
226 // check its value, but this hack seems to work well. | 226 // check its value, but this hack seems to work well. |
227 return !IsLocaleNameTranslated("en", locale_name); | 227 return !IsLocaleNameTranslated("en", locale_name); |
228 } | 228 } |
229 | 229 |
230 #if !defined(OS_MACOSX) | |
Evan Martin
2010/09/21 18:52:20
I think we disable the unused function warnings al
| |
230 bool IsLocaleAvailable(const std::string& locale, | 231 bool IsLocaleAvailable(const std::string& locale, |
231 const FilePath& locale_path) { | 232 const FilePath& locale_path) { |
232 // If locale has any illegal characters in it, we don't want to try to | 233 // If locale has any illegal characters in it, we don't want to try to |
233 // load it because it may be pointing outside the locale data file directory. | 234 // load it because it may be pointing outside the locale data file directory. |
234 if (!file_util::IsFilenameLegal(ASCIIToUTF16(locale))) | 235 if (!file_util::IsFilenameLegal(ASCIIToUTF16(locale))) |
235 return false; | 236 return false; |
236 | 237 |
237 // IsLocalePartiallyPopulated() can be called here for an early return w/o | 238 // IsLocalePartiallyPopulated() can be called here for an early return w/o |
238 // checking the resource availability below. It'd help when Chrome is run | 239 // checking the resource availability below. It'd help when Chrome is run |
239 // under a system locale Chrome is not localized to (e.g.Farsi on Linux), | 240 // under a system locale Chrome is not localized to (e.g.Farsi on Linux), |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
317 base::i18n::GetLanguageAndRegionFromOS(&language, ®ion); | 318 base::i18n::GetLanguageAndRegionFromOS(&language, ®ion); |
318 std::string ret; | 319 std::string ret; |
319 if (!language.empty()) | 320 if (!language.empty()) |
320 ret.append(language); | 321 ret.append(language); |
321 if (!region.empty()) { | 322 if (!region.empty()) { |
322 ret.append("-"); | 323 ret.append("-"); |
323 ret.append(region); | 324 ret.append(region); |
324 } | 325 } |
325 return ret; | 326 return ret; |
326 } | 327 } |
328 #endif | |
327 | 329 |
328 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 330 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
329 // Split and normalize the language list specified by LANGUAGE environment. | 331 // Split and normalize the language list specified by LANGUAGE environment. |
330 // LANGUAGE environment specifies a priority list of user prefered locales for | 332 // LANGUAGE environment specifies a priority list of user prefered locales for |
331 // application UI messages. Locales are separated by ':' character. The format | 333 // application UI messages. Locales are separated by ':' character. The format |
332 // of a locale is: language[_territory[.codeset]][@modifier] | 334 // of a locale is: language[_territory[.codeset]][@modifier] |
333 // | 335 // |
334 // This function splits the language list and normalizes each locale into | 336 // This function splits the language list and normalizes each locale into |
335 // language[-territory] format, eg. fr, zh-CN, etc. | 337 // language[-territory] format, eg. fr, zh-CN, etc. |
336 void SplitAndNormalizeLanguageList(const std::string& env_language, | 338 void SplitAndNormalizeLanguageList(const std::string& env_language, |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
861 for (size_t i = 0; i < arraysize(kAcceptLanguageList); ++i) { | 863 for (size_t i = 0; i < arraysize(kAcceptLanguageList); ++i) { |
862 if (!IsLocaleNameTranslated(kAcceptLanguageList[i], display_locale)) | 864 if (!IsLocaleNameTranslated(kAcceptLanguageList[i], display_locale)) |
863 // TODO(jungshik) : Put them at the of the list with language codes | 865 // TODO(jungshik) : Put them at the of the list with language codes |
864 // enclosed by brackets instead of skipping. | 866 // enclosed by brackets instead of skipping. |
865 continue; | 867 continue; |
866 locale_codes->push_back(kAcceptLanguageList[i]); | 868 locale_codes->push_back(kAcceptLanguageList[i]); |
867 } | 869 } |
868 } | 870 } |
869 | 871 |
870 } // namespace l10n_util | 872 } // namespace l10n_util |
OLD | NEW |