Lines Matching defs:locale
25 #include "src/objects/js-locale-inl.h"
26 #include "src/objects/js-locale.h"
346 // fits in the Latin1 range in the *root locale*. It does not hold
347 // for ToUpperCase even in the root locale.
433 // to assume that for given locale NumberingSystem constructor produces the
449 // Convert BCP47 into ICU locale format.
526 // Build the shortened locale; eg, convert xx_Yyyy_ZZ to xx_ZZ.
528 // If locale has a script tag then return true and the locale without the
546 bool ValidateResource(const icu::Locale locale, const char* path,
550 UResourceBundle* bundle = ures_open(path, locale.getName(), &status);
563 if ((locale.getCountry()[0] != '\0') && (locale.getScript()[0] != '\0')) {
565 std::string without_country(locale.getLanguage());
566 without_country = without_country.append("-").append(locale.getScript());
568 } else if ((locale.getCountry()[0] != '\0') ||
569 (locale.getScript()[0] != '\0')) {
571 std::string language(locale.getLanguage());
584 for (const std::string& locale : icu_available_locales) {
586 if (!ValidateResource(icu::Locale(locale.c_str()), path, validate_key)) {
588 if (locale != "nb") {
597 locales.insert(locale);
599 if (RemoveLocaleScriptTag(locale, &shortened_locale)) {
607 Maybe<std::string> Intl::ToLanguageTag(const icu::Locale& locale) {
609 std::string res = locale.toLanguageTag<std::string>(status);
646 bool IsTwoLetterLanguage(const std::string& locale) {
648 return locale.length() == 2 && IsAsciiLower(locale[0]) &&
649 IsAsciiLower(locale[1]);
652 bool IsDeprecatedOrLegacyLanguage(const std::string& locale) {
653 // Check if locale is one of the deprecated language tags:
654 return locale == "in" || locale == "iw" || locale == "ji" || locale == "jw" ||
655 locale == "mo" ||
656 // Check if locale is one of the legacy language tags:
657 locale == "sh" || locale == "tl" || locale == "no";
664 // Canonicalize the locale.
669 std::string locale = locale_in;
671 if (locale.length() == 0 ||
672 !String::IsAscii(locale.data(), static_cast<int>(locale.length()))) {
677 isolate->factory()->NewStringFromAsciiChecked(locale.c_str())),
686 if ((IsTwoLetterLanguage(locale) && !IsDeprecatedOrLegacyLanguage(locale)) ||
687 locale == "fil") {
688 return Just(locale);
693 std::transform(locale.begin(), locale.end(), locale.begin(), ToAsciiLower);
699 // propose to Ecma 402 to put a limit on the locale length or change ICU to
700 // handle long locale names better. See
707 icu::Locale icu_locale = icu::Locale::forLanguageTag(locale.c_str(), error);
714 isolate->factory()->NewStringFromAsciiChecked(locale.c_str())),
718 // Use LocaleBuilder to validate locale.
726 isolate->factory()->NewStringFromAsciiChecked(locale.c_str())),
735 isolate->factory()->NewStringFromAsciiChecked(locale.c_str())),
763 std::string locale(locale_str->ToCString().get());
765 if (!IsStructurallyValidLanguageTag(locale)) {
770 return CanonicalizeLanguageTag(isolate, locale);
901 // in the root locale needs to be adjusted for az, lt and tr because even case
1721 const std::string& locale) {
1722 // 1. Let candidate be locale.
1723 std::string candidate = locale;
1763 ParsedLocale ParseBCP47Locale(const std::string& locale) {
1764 size_t length = locale.length();
1768 if ((length > 1) && (locale[1] == '-')) {
1772 DCHECK(locale[0] == 'x' || locale[0] == 'i');
1773 parsed_locale.no_extensions_locale = locale;
1777 size_t unicode_extension_start = locale.find("-u-");
1781 parsed_locale.no_extensions_locale = locale;
1785 size_t private_extension_start = locale.find("-x-");
1790 parsed_locale.no_extensions_locale = locale;
1794 const std::string beginning = locale.substr(0, unicode_extension_start);
1801 if (locale[i] != '-') continue;
1803 if (locale[i + 2] == '-') {
1811 const std::string end = locale.substr(unicode_extension_end);
1813 parsed_locale.extension = locale.substr(
1825 // 2. For each element locale of requestedLocales in List order, do
1826 for (const std::string& locale : requested_locales) {
1827 // 2. a. Let noExtensionsLocale be the String value that is locale
1828 // with all Unicode locale extension sequences removed.
1830 ParseBCP47Locale(locale).no_extensions_locale;
1837 // 2. c. If availableLocale is not undefined, append locale to the
1840 subset.push_back(locale);
1862 // skip invalid locale such as no-NO-NY
1900 // operation. Options specified through Unicode locale extension sequences must
1902 // separately. The abstract operation returns a record with a [[locale]] field,
1903 // whose value is the language tag of the selected locale, which must be an
1904 // element of availableLocales. If the language tag of the request locale that
1905 // led to the selected locale contained a Unicode locale extension sequence,
1907 // the first Unicode locale extension sequence within the request locale
1943 // availableLocales has a matching locale when using the Best Fit Matcher
2235 bool IsValidExtension(const icu::Locale& locale, const char* key,
2243 T::getKeywordValuesForLocale(key, icu::Locale(locale.getBaseName()),
2261 bool Intl::IsValidCollation(const icu::Locale& locale,
2265 return IsValidExtension<icu::Collator>(locale, "collation", value);
2277 bool Intl::IsValidCalendar(const icu::Locale& locale,
2279 return IsValidExtension<icu::Calendar>(locale, "calendar", value);
2384 // 2. For each element locale of requestedLocales in List order, do
2385 for (const std::string& locale : requested_locales) {
2386 // 2. a. Let noExtensionsLocale be the String value that is locale
2387 // with all Unicode locale extension sequences removed.
2388 ParsedLocale parsed_locale = ParseBCP47Locale(locale);
2396 // 2. c. If availableLocale is not undefined, append locale to the
2400 // can use ICU to parse the unicode locale extension sequence
2403 // There's no need to separate the unicode locale extensions
2404 // right here. Instead just return the available locale with the
2407 // 2. c. i. Set result.[[locale]] to availableLocale.
2408 // 2. c. ii. If locale and noExtensionsLocale are not the same
2411 // the first substring of locale that is a Unicode locale
2420 // 4. Set result.[[locale]] to defLocale.
2441 std::string locale;
2444 locale = BestFitMatcher(isolate, available_locales, requested_locales);
2446 locale = LookupMatcher(isolate, available_locales, requested_locales);
2449 Maybe<icu::Locale> maybe_icu_locale = CreateICULocale(locale);