Significant incompatible Flutter internationalization change

211 views
Skip to first unread message

Hans Muller

unread,
Oct 11, 2017, 7:05:02 PM10/11/17
to Flutter Dev

We decided to refactor the Flutter support for internationalization: the localizations for the widgets and material libraries have been moved into a separate package called flutter_localizations. By default Flutter will only provide US English localizations.

Apps that want to include the localizations for other languages will have to add a pubspec.yaml dependency on flutter_localizations:

  dependencies:
    flutter:
      sdk: flutter
    flutter_localizations:
      sdk: flutter

They'll also need to add an import and specify localizationsDelegates and supportedLocales for MaterialApp:

import 'package:flutter_localizations/flutter_localizations.dart';

  new MaterialApp(
   localizationsDelegates: GlobalMaterialLocalizations.delegates,
   supportedLocales: [
      const Locale('en', 'US'), // English
      const Locale('he', 'IL'), // Hebrew
      // ... the other locales your app supports
    ],
    // ...
  )

The Flutter internationalization tutorial https://flutter.io/tutorials/internationalization/ will be updated shortly, to reflect these changes.

The stocks example has been updated to use the new flutter_localizations package.

If you run into trouble updating an app for these changes you can contact me directly or via the usual channels.

qureshi....@gmail.com

unread,
Oct 23, 2017, 11:34:50 AM10/23/17
to Flutter Dev
Hi 

I am a veteran Java developer (did programming in early 2000s) and returning to development for my project. I am thrilled by Flutter and how easy to program, execute and test. 

However, I found documentation a bit confusing atleast for Internationalization topic. I think the document should start with a simple example then expand on design choices.

What I would like to see/try is to change the title of my app based on the device locale. I spent last four hours trying and reading the topic again and again before giving up. 

It will be really helpful if you can give a simple example.

Thanks
Ghaz

Hans Muller

unread,
Oct 23, 2017, 1:47:27 PM10/23/17
to qureshi....@gmail.com, Flutter Dev
I'm sorry that the i18n API isn't simpler. Unfortunately we needed to make it flexible enough to accommodate many approaches to localization.

I've attached an example of the API that just displays a localized title.  To keep things simple I didn't use the Dart intl package.  Let me know if you can sort out how it works.

- Hans

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

main.dart

Seth Ladd

unread,
Oct 23, 2017, 2:16:14 PM10/23/17
to Hans Muller, qureshi....@gmail.com, Flutter Dev
Thanks Hans. I created a gist from your sample: https://gist.github.com/sethladd/4344b9cc570fc59539fe83d72510d544

Ghazanfar Qureshi

unread,
Oct 23, 2017, 4:44:10 PM10/23/17
to Hans Muller, Flutter Dev
Hi Hans,

Thanks for the prompt reply. I will give it a try and respond in a day or two. I take a look at the file and it looks good (means thats what I was looking for).

Thanks
Ghaz
Reply all
Reply to author
Forward
0 new messages