Flutter – Flame and Internationalization?

Issue

what is the recommended i18n method for Dart programs without Flutter widgets (Games using Flame package)?

I tried the dart Intl package and the Flutter intl package with the Android Studio plugin but can’t get it running properly. I use DeviceLocale to get the locale but want to use proper classes/methods to read the strings in each locale from files (e.g. arb), but I didn’t figure out how to do it with the given tools. The Flutter intl package always wants a context for translations which I don’t have necessarily in a Flame game. Of course I have a working solution based on a Translation class and Maps, but I expect there should be a common way to do this properly.

Does anyone have examples on how to implement this in a clean way?

Regards,
Ralph

Solution

Since Flutter Intl 1.8.0 version, you should be able to reference string keys without passing the context.

Answered By – Brad

Answer Checked By – Gilberto Lyons (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *