Ameer
Ameer

Reputation: 725

Flutter : Restrict price localization to english only

My app supports two localizations 1] English 2] Arabic. Localization is working perfectly throughout the app.

But there are certain scenarios where I need to show text only in the English language but app changing it to as per selected localization. So all prices are shown in Arabic for Arabic localization.

I tried to put explicit Locale (NOT sure whether it is supposed to do like this) in a Text widget but still, that didn't work for me.

Text('3434', // Dynamic String from server
      locale: Locale('en'),
      style: TextStyle(fontSize: 16))

Actual Result When Arabic Localization is selected :

enter image description here

Expected Result :

enter image description here

Upvotes: 0

Views: 1150

Answers (3)

aminbadri7
aminbadri7

Reputation: 129

Text(item.price, textDirection: TextDirection.ltr,) will make the TextDirection to be always in English 'ltr' left to right.

I hope that helps.

Upvotes: 0

hashir abdulbasheer
hashir abdulbasheer

Reputation: 61

set font-family specifically to those texts that doesn't need the arabic font. That way, it will override the default one.

Upvotes: 1

Ameer
Ameer

Reputation: 725

We need to set fontFamily to Text Widget to whichever language-specific you want. For me, I just set the fontFamily like this,

Text(
    value,
    style: TextStyle(fontSize: 16, fontFamily: 'OpenSans'),
  ),

Hope this will be useful for someone.

Upvotes: 0

Related Questions