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

Unified Diff: chrome/browser/resources/print_preview/print_preview_utils.js

Issue 8922021: Print Preview: Fixing parsing of numberFormat for several locales. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed fallback format Created 9 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/print_preview/print_preview_utils.js
diff --git a/chrome/browser/resources/print_preview/print_preview_utils.js b/chrome/browser/resources/print_preview/print_preview_utils.js
index 9c192418fca97f4d31ec43ea5736a2033c629b53..81d8488b7fb221c7151d46bde0147997c70bbff5 100644
--- a/chrome/browser/resources/print_preview/print_preview_utils.js
+++ b/chrome/browser/resources/print_preview/print_preview_utils.js
@@ -247,3 +247,19 @@ function convertMillimetersToPoints(value) {
function convertPointsToMillimeters(value) {
return value / POINTS_PER_MILLIMETER;
}
+
+/**
+ * Parses |numberFormat| and extracts the symbols used for the thousands point
+ * and decimal point.
+ * @param {string} numberFormat The formatted version of the number 12345678.
+ * @return {!array.<string>} The extracted symbols in the order
+ * [thousandsSymbol, decimalSymbol]]. For example
+ * parseNumberFormat("123,456.78") returns [",", "."].
+ */
+function parseNumberFormat(numberFormat) {
+ if (!numberFormat)
+ numberFormat = '';
+ var regex = /^(\d+)(\W{0,1})(\d+)(\W{0,1})(\d+)$/;
+ var matches = numberFormat.match(regex) || ['','',',','','.'];
+ return [matches[2], matches[4]];
+}

Powered by Google App Engine
This is Rietveld 408576698