1

For localising my app I am using strings.xml for three languages

I have a statement

current balance: Rs. %0.2f

I populate this at runtime by using

getResources().getString(R.string.home_survey_text, user.demographicsPrice)

this seems to be working for English and Hindi where I get value as

current balance: Rs. 1.45

but for Kannada I am gettting

current balance: Rs. 1,45.

the comma is incorrectly being displayed. Need help with the same, stackoverflow reading recommendation anything that would help is appreciated.

anurag145
  • 145
  • 13
  • What do you mean by "comma is incorrectly displayed" ? What is incorrect ? what did you expect ? – vincrichaud Mar 12 '19 at 10:45
  • Localization is a pain in Android or any application for that matter. You'd need to use the NumberFormat or code a special case, linked here: https://en.wikipedia.org/wiki/Decimal_separator . The comma delimiter is used instead of the dot delimiter in several languages. It appears Android doesn't have one correctly set for Kannada. You might want to read these too; Indian Number System: https://stackoverflow.com/questions/5379231/displaying-currency-in-indian-numbering-format Currency Symbol for Android: https://developer.android.com/reference/java/util/Currency – MD Naseem Ashraf Mar 12 '19 at 11:01

2 Answers2

0

You can user a formatter to format your number however you choose.

NumberFormat formatter = new DecimalFormat("#.#");
String number = formatter.format(1/3);

number will be 0.3

NumberFormat formatter = new DecimalFormat("#,#");
String number = formatter.format(1/3);

number will be 0,3

baselsader
  • 424
  • 2
  • 4
  • 16
0

Changing values-kn_IN to values-kn in folder structure did the trick.

anurag145
  • 145
  • 13