Jesway / flutter_translate

Flutter Translate is a fully featured localization / internationalization (i18n) library for Flutter.
MIT License
403 stars 118 forks source link

Retrieve the current device locale and initialize it before runApp #15

Closed SiyrisSoul closed 5 years ago

SiyrisSoul commented 5 years ago

Fixes issue #13 and possibly #14 but I don't have an iOS device to test on. Takes into account if there are preferences on the device and if not loads the device locale.

bratan commented 5 years ago

I just did some tests on both iOS simulator and an iPhone and there are some issues.

On iOS, in release mode, the Platform.localeName returns null and it seems this is intended, based on https://github.com/flutter/flutter/issues/24747

In debug mode, it always returns the region locale, instead of the selected language, so here we have the issue from https://github.com/bratan/flutter_translate/issues/14.

So basically this would only fix the black screen on Android for https://github.com/bratan/flutter_translate/issues/13

I`m going to do some more tests today and probably implement a platform channel call for iOS to retrieve the current device language during startup.

SiyrisSoul commented 5 years ago

Thanks for making me aware of that behavior! I need to get an iOS device now I suppose :grimacing:

SiyrisSoul commented 5 years ago

I just did some tests on both iOS simulator and an iPhone and there are some issues.

On iOS, in release mode, the Platform.localeName returns null and it seems this is intended, based on flutter/flutter#24747

In debug mode, it always returns the region locale, instead of the selected language, so here we have the issue from #14.

So basically this would only fix the black screen on Android for #13

I`m going to do some more tests today and probably implement a platform channel call for iOS to retrieve the current device language during startup.

Any update on this? If you are busy I could implement the platform channel call, but you would have to test it as I don't have a way to test on iOS :)

bratan commented 5 years ago

I`m going to implement it most likely tomorrow.

bratan commented 5 years ago

@TutOsirisOm - It's done. We now have a consistent implementation for both Android/iOS.