Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent digits to change from English to Arabic on Locale updated android

Tags:

android

locale

I'm providing Arabic support for the already-completed app. On changing the app language to Arabic, numbers are displaying with Arabic digits for the XML strings.

But my problem is on executing the following code

getString(R.string.value, ++value);

values

<string name="value">Value : %d</string>

values-ar

<string name="value">%d :القيمة </string>

with English, it is working fine.

Value: 1

On changing the language to Arabic (Appearing in Arabic). It must be in English (0-9)

Value : (Number in Arabic)

Please provide a solution to my problem.

like image 837
kashyap Avatar asked Oct 25 '25 03:10

kashyap


1 Answers

You can change the locale of the number using String.format to always be shown in English:

String.format(Locale.ENGLISH, getString(R.string.value), ++value)
like image 79
aminography Avatar answered Oct 26 '25 18:10

aminography