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

Side by Side Diff: src/js/i18n.js

Issue 2588963002: Turn on icu_case_mapping by default (Closed)
Patch Set: tighten up comparison ops Created 3 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
« no previous file with comments | « src/flag-definitions.h ('k') | test/webkit/fast/js/string-capitalization-expected.txt » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project 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 // ECMAScript 402 API implementation. 5 // ECMAScript 402 API implementation.
6 6
7 /** 7 /**
8 * Intl object is a single object that has some named properties, 8 * Intl object is a single object that has some named properties,
9 * all of which are constructors. 9 * all of which are constructors.
10 */ 10 */
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 1117
1118 1118
1119 AddBoundMethod(GlobalIntlCollator, 'compare', compare, 2, 'collator', false); 1119 AddBoundMethod(GlobalIntlCollator, 'compare', compare, 2, 'collator', false);
1120 1120
1121 /** 1121 /**
1122 * Verifies that the input is a well-formed ISO 4217 currency code. 1122 * Verifies that the input is a well-formed ISO 4217 currency code.
1123 * Don't uppercase to test. It could convert invalid code into a valid one. 1123 * Don't uppercase to test. It could convert invalid code into a valid one.
1124 * For example \u00DFP (Eszett+P) becomes SSP. 1124 * For example \u00DFP (Eszett+P) becomes SSP.
1125 */ 1125 */
1126 function isWellFormedCurrencyCode(currency) { 1126 function isWellFormedCurrencyCode(currency) {
1127 return typeof currency == "string" && currency.length == 3 && 1127 return typeof currency === "string" && currency.length === 3 &&
1128 IS_NULL(%regexp_internal_match(/[^A-Za-z]/, currency)); 1128 IS_NULL(%regexp_internal_match(/[^A-Za-z]/, currency));
1129 } 1129 }
1130 1130
1131 1131
1132 /** 1132 /**
1133 * Returns the valid digit count for a property, or throws RangeError on 1133 * Returns the valid digit count for a property, or throws RangeError on
1134 * a value out of the range. 1134 * a value out of the range.
1135 */ 1135 */
1136 function getNumberOption(options, property, min, max, fallback) { 1136 function getNumberOption(options, property, min, max, fallback) {
1137 var value = options[property]; 1137 var value = options[property];
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
2017 language = GetDefaultICULocaleJS(); 2017 language = GetDefaultICULocaleJS();
2018 } else if (IS_STRING(locales)) { 2018 } else if (IS_STRING(locales)) {
2019 language = canonicalizeLanguageTag(locales); 2019 language = canonicalizeLanguageTag(locales);
2020 } else { 2020 } else {
2021 var locales = initializeLocaleList(locales); 2021 var locales = initializeLocaleList(locales);
2022 language = locales.length > 0 ? locales[0] : GetDefaultICULocaleJS(); 2022 language = locales.length > 0 ? locales[0] : GetDefaultICULocaleJS();
2023 } 2023 }
2024 2024
2025 // StringSplit is slower than this. 2025 // StringSplit is slower than this.
2026 var pos = %StringIndexOf(language, '-', 0); 2026 var pos = %StringIndexOf(language, '-', 0);
2027 if (pos != -1) { 2027 if (pos !== -1) {
2028 language = %_Call(StringSubstring, language, 0, pos); 2028 language = %_Call(StringSubstring, language, 0, pos);
2029 } 2029 }
2030 2030
2031 var CUSTOM_CASE_LANGUAGES = ['az', 'el', 'lt', 'tr']; 2031 var CUSTOM_CASE_LANGUAGES = ['az', 'el', 'lt', 'tr'];
2032 var langIndex = %ArrayIndexOf(CUSTOM_CASE_LANGUAGES, language, 0); 2032 var langIndex = %ArrayIndexOf(CUSTOM_CASE_LANGUAGES, language, 0);
2033 if (langIndex == -1) { 2033 if (langIndex === -1) {
jungshik at Google 2017/01/10 01:22:45 I tightened the comparison here just in case altho
2034 // language-independent case conversion. 2034 // language-independent case conversion.
2035 return isToUpper ? %StringToUpperCaseI18N(s) : %StringToLowerCaseI18N(s); 2035 return isToUpper ? %StringToUpperCaseI18N(s) : %StringToLowerCaseI18N(s);
2036 } 2036 }
2037 return %StringLocaleConvertCase(s, isToUpper, 2037 return %StringLocaleConvertCase(s, isToUpper,
2038 CUSTOM_CASE_LANGUAGES[langIndex]); 2038 CUSTOM_CASE_LANGUAGES[langIndex]);
jungshik at Google 2017/01/10 01:22:45 In runtime-i18n.cc, CUSTOM_CASE_LANGUAGES[langInde
2039 } 2039 }
2040 2040
2041 /** 2041 /**
2042 * Compares this and that, and returns less than 0, 0 or greater than 0 value. 2042 * Compares this and that, and returns less than 0, 0 or greater than 0 value.
2043 * Overrides the built-in method. 2043 * Overrides the built-in method.
2044 */ 2044 */
2045 OverrideFunction(GlobalString.prototype, 'localeCompare', function(that) { 2045 OverrideFunction(GlobalString.prototype, 'localeCompare', function(that) {
2046 if (IS_NULL_OR_UNDEFINED(this)) { 2046 if (IS_NULL_OR_UNDEFINED(this)) {
2047 throw %make_type_error(kMethodInvokedOnNullOrUndefined); 2047 throw %make_type_error(kMethodInvokedOnNullOrUndefined);
2048 } 2048 }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
2197 } 2197 }
2198 ); 2198 );
2199 2199
2200 %FunctionRemovePrototype(FormatDateToParts); 2200 %FunctionRemovePrototype(FormatDateToParts);
2201 2201
2202 utils.Export(function(to) { 2202 utils.Export(function(to) {
2203 to.FormatDateToParts = FormatDateToParts; 2203 to.FormatDateToParts = FormatDateToParts;
2204 }); 2204 });
2205 2205
2206 }) 2206 })
OLDNEW
« no previous file with comments | « src/flag-definitions.h ('k') | test/webkit/fast/js/string-capitalization-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698