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

Side by Side Diff: src/i18n.js

Issue 1231613006: Make NumberFormat use the ICU currency data, fix bug in NumberFormat (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Use short form of license Created 5 years, 5 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
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 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 'currencyDisplay', 'string', ['code', 'symbol', 'name'], 'symbol'); 1092 'currencyDisplay', 'string', ['code', 'symbol', 'name'], 'symbol');
1093 if (internalOptions.style === 'currency') { 1093 if (internalOptions.style === 'currency') {
1094 defineWEProperty(internalOptions, 'currency', %StringToUpperCase(currency)); 1094 defineWEProperty(internalOptions, 'currency', %StringToUpperCase(currency));
1095 defineWEProperty(internalOptions, 'currencyDisplay', currencyDisplay); 1095 defineWEProperty(internalOptions, 'currencyDisplay', currencyDisplay);
1096 } 1096 }
1097 1097
1098 // Digit ranges. 1098 // Digit ranges.
1099 var mnid = getNumberOption(options, 'minimumIntegerDigits', 1, 21, 1); 1099 var mnid = getNumberOption(options, 'minimumIntegerDigits', 1, 21, 1);
1100 defineWEProperty(internalOptions, 'minimumIntegerDigits', mnid); 1100 defineWEProperty(internalOptions, 'minimumIntegerDigits', mnid);
1101 1101
1102 var mnfd = getNumberOption(options, 'minimumFractionDigits', 0, 20, 0); 1102 var mnfd = options['minimumFractionDigits'];
1103 defineWEProperty(internalOptions, 'minimumFractionDigits', mnfd); 1103 var mxfd = options['maximumFractionDigits'];
1104 if (!IS_UNDEFINED(mnfd) || !internalOptions.style === 'currency') {
1105 mnfd = getNumberOption(options, 'minimumFractionDigits', 0, 20, 0);
1106 defineWEProperty(internalOptions, 'minimumFractionDigits', mnfd);
1107 }
1104 1108
1105 var mxfd = getNumberOption(options, 'maximumFractionDigits', mnfd, 20, 3); 1109 if (!IS_UNDEFINED(mxfd) || !internalOptions.style === 'currency') {
1106 defineWEProperty(internalOptions, 'maximumFractionDigits', mxfd); 1110 mnfd = IS_UNDEFINED(mnfd) ? 0 : mnfd;
1111 fallback_limit = (mnfd > 3) ? mnfd : 3;
1112 mxfd = getNumberOption(options, 'maximumFractionDigits', mnfd, 20, fallback_ limit);
1113 defineWEProperty(internalOptions, 'maximumFractionDigits', mxfd);
1114 }
1107 1115
1108 var mnsd = options['minimumSignificantDigits']; 1116 var mnsd = options['minimumSignificantDigits'];
1109 var mxsd = options['maximumSignificantDigits']; 1117 var mxsd = options['maximumSignificantDigits'];
1110 if (!IS_UNDEFINED(mnsd) || !IS_UNDEFINED(mxsd)) { 1118 if (!IS_UNDEFINED(mnsd) || !IS_UNDEFINED(mxsd)) {
1111 mnsd = getNumberOption(options, 'minimumSignificantDigits', 1, 21, 0); 1119 mnsd = getNumberOption(options, 'minimumSignificantDigits', 1, 21, 0);
1112 defineWEProperty(internalOptions, 'minimumSignificantDigits', mnsd); 1120 defineWEProperty(internalOptions, 'minimumSignificantDigits', mnsd);
1113 1121
1114 mxsd = getNumberOption(options, 'maximumSignificantDigits', mnsd, 21, 21); 1122 mxsd = getNumberOption(options, 'maximumSignificantDigits', mnsd, 21, 21);
1115 defineWEProperty(internalOptions, 'maximumSignificantDigits', mxsd); 1123 defineWEProperty(internalOptions, 'maximumSignificantDigits', mxsd);
1116 } 1124 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 if (%HasOwnProperty(internalOptions, 'minimumSignificantDigits')) { 1158 if (%HasOwnProperty(internalOptions, 'minimumSignificantDigits')) {
1151 defineWEProperty(resolved, 'minimumSignificantDigits', UNDEFINED); 1159 defineWEProperty(resolved, 'minimumSignificantDigits', UNDEFINED);
1152 } 1160 }
1153 if (%HasOwnProperty(internalOptions, 'maximumSignificantDigits')) { 1161 if (%HasOwnProperty(internalOptions, 'maximumSignificantDigits')) {
1154 defineWEProperty(resolved, 'maximumSignificantDigits', UNDEFINED); 1162 defineWEProperty(resolved, 'maximumSignificantDigits', UNDEFINED);
1155 } 1163 }
1156 var formatter = %CreateNumberFormat(requestedLocale, 1164 var formatter = %CreateNumberFormat(requestedLocale,
1157 internalOptions, 1165 internalOptions,
1158 resolved); 1166 resolved);
1159 1167
1160 // We can't get information about number or currency style from ICU, so we
1161 // assume user request was fulfilled.
1162 if (internalOptions.style === 'currency') { 1168 if (internalOptions.style === 'currency') {
1163 ObjectDefineProperty(resolved, 'currencyDisplay', {value: currencyDisplay, 1169 ObjectDefineProperty(resolved, 'currencyDisplay', {value: currencyDisplay,
1164 writable: true}); 1170 writable: true});
1165 } 1171 }
1166 1172
1167 %MarkAsInitializedIntlObjectOfType(numberFormat, 'numberformat', formatter); 1173 %MarkAsInitializedIntlObjectOfType(numberFormat, 'numberformat', formatter);
1168 ObjectDefineProperty(numberFormat, 'resolved', {value: resolved}); 1174 ObjectDefineProperty(numberFormat, 'resolved', {value: resolved});
1169 1175
1170 return numberFormat; 1176 return numberFormat;
1171 } 1177 }
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after
2099 } 2105 }
2100 2106
2101 var locales = %_Arguments(0); 2107 var locales = %_Arguments(0);
2102 var options = %_Arguments(1); 2108 var options = %_Arguments(1);
2103 return toLocaleDateTime( 2109 return toLocaleDateTime(
2104 this, locales, options, 'time', 'time', 'dateformattime'); 2110 this, locales, options, 'time', 'time', 'dateformattime');
2105 } 2111 }
2106 ); 2112 );
2107 2113
2108 }) 2114 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698