antonio
antonio

Reputation: 57

Forcing language to not change

I have app in android studio and When i install APK and Language is English,

it show language of app like i want, but when phone language is different like Persian, it show other language in app and i don't want it...

how i can force app to use same English even language of phone changed?

my application is in Android studio and just one line have problem, mean there is a line words in application, and when i change language phone, it change to a different language same i don't want.

this is my main.xml (same line code

   <TextView
        android:id="@+id/diffText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Dhuhar After one hour  10 min"
        android:textColor="#ffffff"
        android:textSize="16dip"
        android:textStyle="bold"></TextView>
</LinearLayout>

And this one is not available in my string.xml, it mean it not translated, correct?

and cause "one hour 10min" is not stable, there is easy way i force it to use for all language same use for english?

Upvotes: 0

Views: 763

Answers (3)

Kumar Kalluri
Kumar Kalluri

Reputation: 513

If you want only english for all languages, dont set different language xml.. Just provide only default strings.xml.. app will show what ever text in strings.xml.

Upvotes: 1

xdevs23
xdevs23

Reputation: 3994

If you don't define your string in other language files (only write <string name="yourstring" translatable="false">Your english string</string>) then you will get your expected behavior.

That is because it takes the strings from values/ if they are not available in the specific folder for the current language (e.g. values-de/)

Upvotes: 0

antonio
antonio

Reputation: 57

I set below code in oncreate and solved

Locale.setDefault(Locale.ENGLISH);

Upvotes: 1

Related Questions