Skip to content

Instantly share code, notes, and snippets.


ijoschek/.\lib\localizations.dart Secret

Last active Dec 29, 2018
What would you like to do?
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:intl/intl.dart';
import 'l10n/messages_all.dart';
class AppLocalizations {
static Future<AppLocalizations> load(Locale locale) {
final String name =
locale.countryCode.isEmpty ? locale.languageCode : locale.toString();
final String localeName = Intl.canonicalizedLocale(name);
return initializeMessages(localeName).then((_) {
Intl.defaultLocale = localeName;
return AppLocalizations();
static AppLocalizations of(BuildContext context) {
return Localizations.of<AppLocalizations>(context, AppLocalizations);
title() => Intl.message(
'Counter Tutorial',
name: "title",
desc: "Name of the tutorial",
text(counter) => Intl.message(
'You have pushed the button $counter times:',
name: "text",
args: [counter],
desc: "Our Text to localize",
class AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> {
const AppLocalizationsDelegate();
bool isSupported(Locale locale) => ['en', 'de', 'ru'].contains(locale.languageCode);
Future<AppLocalizations> load(Locale locale) => AppLocalizations.load(locale);
bool shouldReload(AppLocalizationsDelegate old) => false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment