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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/payments/CurrencyStringFormatter.java

Issue 2250313002: Show Canadian dollars as"CAD $5.00" instead of "CAD CA$5.00". (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use 'new Locale' constructor instead of 'Locale.forLanguageTag' static method. Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/java_sources.gni » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/payments/CurrencyStringFormatter.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/CurrencyStringFormatter.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/CurrencyStringFormatter.java
index 524d852de5ba0adf1f2b8ffb244449073a877a03..dd8a8a19240febe3460301f8e51924f0896d9be7 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/payments/CurrencyStringFormatter.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/CurrencyStringFormatter.java
@@ -78,14 +78,21 @@ public class CurrencyStringFormatter {
// The spec does not limit the currencies to official ISO 4217 currency code list, which
// is used by java.util.Currency. For example, "BTX" (bitcoin) is not an official ISO
// 4217 currency code, but is allowed by the spec.
- currencySymbol = currencyCode;
+ currencySymbol = "";
defaultFractionDigits = 0;
}
- // If the currency symobl is the same as the currency code, do not display it as part of the
- // amount. The UI already shows the currency code, so there's no need to show duplicate
- // information.
- mCurrencySymbol = currencySymbol.equals(currencyCode) ? "" : currencySymbol;
+ // If the prefix of the currency symbol matches the prefix of the currency code, remove the
+ // matching prefix from the symbol. The UI already shows the currency code, so there's no
+ // need to show duplicate information.
+ String symbol = "";
+ for (int i = 0; i < currencySymbol.length(); i++) {
+ if (i >= currencyCode.length() || currencySymbol.charAt(i) != currencyCode.charAt(i)) {
+ symbol = currencySymbol.substring(i);
+ break;
+ }
+ }
+ mCurrencySymbol = symbol;
mDefaultFractionDigits = defaultFractionDigits;
« no previous file with comments | « no previous file | chrome/android/java_sources.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698