flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond

Home Page:https://flutter.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add suport for Android 13 per-app language preferences

akadatsky opened this issue · comments

In Android 13 new feature - Per-app language preferences:
https://developer.android.com/guide/topics/resources/app-languages

Could you add its support to Flutter?

wait this issue.

Is there any update on this?

Meanwhile, we can just add this support ourselves. juniorise/spooky-mb@ee0083c

commented

As of my experiments the didChangeLocales event handles them pretty well, at least on latest flutter (3.7.x). So it doesn't seem to be any requirement to query the current locale per app language locale, as Flutter already takes that into consideration. Try to change phone's language and per app language and you will see didChangeLocales will always receive the expected locales. For example:

  • if you change per app language to en and change the phone's lang to de, then the event won't fire at all, because per app lang is stronger.
  • if per app lang is on system default, then phone language changes will trigger the event

Flutter even reorders the locales to make a supported locale the first. For example if you set supportedLocales to [en, de] in your MaterialApp and you change your phone's language to fr, then still en will be the first option in the event's list, like [en, fr, de].

For this to work you just need to add the native android locales xml and modify build.gradle described here.

Setting the per app language though needs a plugin, and the https://pub.dev/packages/devicelocale can already do it.