Android Currency Symbol Order

I am on non-English devices, English currencies are formed as follows:

1 $

If I have English, I get the Euro currency:

€ 1

Using

format.setCurrency(Currency.getInstance(currency)); return format.format(amount); 

Found in the documentation:

http://developer.android.com/reference/java/util/Currency.html#getSymbol ()

Returns the localized currency symbol for this currency in the locale. That is, given "USD" and "Locale.US", you will receive "$", but given "USD" and a non-American locale, you will receive "US $".

If the locale specifies only the language, not the language and country (for example, Locale.JAPANESE or {new Locale ("en", "")}, and not Locale.JAPAN or {new Locale ("en", "US") }), the ISO 4217 currency code is returned.

If the locale-specific currency symbol does not exist, the ISO 4217 currency code is returned.

Not the same method, but probably related. Why does this make a difference in the locale of my device for ordering a character in currency? $ 1 is incorrect no matter what language I use.

Is there any way to change this?

+4
source share
1 answer

The behavior of the method is correct.

Not all countries expect a currency symbol before the amount.

If you always want the currency format to match the American expectation, leave the locale as Locale.US . If you want the currency displayed in a localized way, leave your implementation as it is.

See this quick start guide (from Microsoft, at least):

Globalization step by step

I would suggest that you might be trying to achieve is to display the currency in a format appropriate to its language? If this is the case, simply map the language to the currency used before invoking the method.

Please note that the format may even change in the same country. In Canada, it is reasonably widely believed that English speakers use the $ 50.00 format, while French-Canadians can use $ 50.00.

Also see this question in UX:

https://ux.stackexchange.com/questions/22574/where-to-place-currency-symbol-when-localizing-and-what-to-do-with-odd-symbols

+2
source

Source: https://habr.com/ru/post/1435001/


All Articles