Fred’s Flutter Newsletter

Fred’s Flutter Newsletter

Share this post

Fred’s Flutter Newsletter
Fred’s Flutter Newsletter
How To Make Flutter Internationalization Easier

How To Make Flutter Internationalization Easier

Flutter Internationalization The Easy Way

Fred Grott's avatar
Fred Grott
Aug 16, 2024
∙ Paid

Share this post

Fred’s Flutter Newsletter
Fred’s Flutter Newsletter
How To Make Flutter Internationalization Easier
1
Share

The Flutter Localization class handles translation dialogs only and the l10n tool only provides for simple localized messages via the arb files you provide. What you want to do instead is use the intl package to get special messages involving gender, plurals, date-number formatting, and bidirectional text.

In short words the intl package supports both use cases of using latin script to internationalize the app or using their native language script through the systemOS provided fonts.

So it is a good idea to make use of the intl package.

The problem is that it has you write on extra class, specifically this one:

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Show hidden characters
class DemoLocalizations {
DemoLocalizations(this.localeName);
static Future<DemoLocalizations> load(Locale locale) {
final String name =
locale.countryCode == null || locale.countryCode!.isEmpty
? locale.languageCode
: locale.toString();
final String localeName = Intl.canonicalizedLocale(name);
return initializeMessages(localeName).then((_) {
return DemoLocalizations(localeName);
});
}
static DemoLocalizations of(BuildContext context) {
return Localizations.of<DemoLocalizations>(context, DemoLocalizations)!;
}
final String localeName;
String get title {
return Intl.message(
'Hello World',
name: 'title',
desc: 'Title for the Demo application',
locale: localeName,
);
}
}
view raw snippet.dart hosted with ❤ by GitHub

I am going to show you a way to avoid having to write that class by hand.

Share

Keep reading with a 7-day free trial

Subscribe to Fred’s Flutter Newsletter to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Fred Grott
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share