aminsamad / flutter_kurdish_localization

GNU General Public License v3.0
28 stars 15 forks source link

GetX Library support #5

Open H4zh4n opened 1 year ago

H4zh4n commented 1 year ago

The Library works perfectly well with normal MaterialAppusage. however if I use GetX Library which I have to use GetMaterialApp it instead treats ku as Left to Right.

GetX Library : https://pub.dev/packages/get/

Normal MaterialApp :

image

GetX's GetMaterialApp :

image

Any work-around ?

Tabarek commented 1 year ago

this response may be late but i used this in my app as a workaround textDirection: Get.locale == Locale('ku') ? TextDirection.rtl : null, add this in GetMaterialApp

H4zh4n commented 1 year ago

@Tabarek Thanks a bunch 🌸 I used a different approach and it worked out well for me.

For anyone interested, Since user controls the language selection in my app (no automatic language selection based on device language), I just used one of the RTL languages that I probably won't support. these languages are all Right to Left :

Arabic - Locale('ar')
Farsi - Locale('fa')
Hebrew - Locale('he')
Pashto - Locale('ps')
Urdu - Locale('ur')

I just picked he (Hebrew) as default Locale for Kurdi. and in the class that extends Translations I set it up like below :

Map<String, Map<String, String>> get keys => {
      'en': {
        'hello': 'Hello',
      },
      'he': {
        'hello': 'سڵاو',
      },
      'ar': {
        'hello': 'اهلا',
      },
    };

When user chose Kurdish Language I just changed the locale to Hebrew and that was it.

Get.updateLocale(Locale('he'));

Note

This library ( The flutter_kurdish_localization ) was not necessary to use. no need to setup localizationsDelegates with KurdishMaterialLocalizations or KurdishWidgetLocalizations. Normal GetMaterialApp with it's locale and that's it.

H4zh4n commented 1 year ago

Apologies for the Close / Re-open of the issue. I do think it should stay open and let the dev decide whether they want to have something that works with GetX then close it, or have it be as it is and let people use other approaches.