From 8226292c29e0e1d34168177fb5ec3fa11a4c9fd0 Mon Sep 17 00:00:00 2001 From: Yannick Mauray Date: Sun, 14 Nov 2021 21:18:46 +0100 Subject: [PATCH] Fixed : example --- CHANGELOG.md | 8 ++++++ example/lib/app.dart | 40 ------------------------------ example/lib/home_page.dart | 13 ---------- example/lib/main.dart | 50 ++++++++++++++++++++++++++++++++++++-- pubspec.yaml | 2 +- 5 files changed, 57 insertions(+), 56 deletions(-) delete mode 100644 example/lib/app.dart delete mode 100644 example/lib/home_page.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index 10a3e4a..83872f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 1.0.2 + +* Fixed example + +## 1.0.1 + +* Fixed packaging issues + ## 1.0.0 * Initial release. diff --git a/example/lib/app.dart b/example/lib/app.dart deleted file mode 100644 index 38b3e6f..0000000 --- a/example/lib/app.dart +++ /dev/null @@ -1,40 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_localizations/flutter_localizations.dart'; -import 'package:gettext_i18n/gettext_i18n.dart'; - -import 'home_page.dart'; - -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: const HomePage(), - supportedLocales: ['en', 'fr', 'fr_CH'].map((l) => Locale(l)), - localizationsDelegates: [ - GettextLocalizationsDelegate(defaultLanguage: 'en'), - GlobalMaterialLocalizations.delegate, - GlobalWidgetsLocalizations.delegate, - ], - localeListResolutionCallback: (locales, supportedLocales) { - if (locales != null) { - for (var locale in locales) { - var supportedLocale = supportedLocales.where((element) => - element.languageCode == locale.languageCode && - element.countryCode == locale.countryCode); - if (supportedLocale.isNotEmpty) { - return supportedLocale.first; - } - supportedLocale = supportedLocales.where( - (element) => element.languageCode == locale.languageCode); - if (supportedLocale.isNotEmpty) { - return supportedLocale.first; - } - } - } - return null; - }, - ); - } -} diff --git a/example/lib/home_page.dart b/example/lib/home_page.dart deleted file mode 100644 index dc094fa..0000000 --- a/example/lib/home_page.dart +++ /dev/null @@ -1,13 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:gettext_i18n/gettext_i18n.dart'; - -class HomePage extends StatelessWidget { - const HomePage({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return Center( - child: Text(context.t('Hello, world !')), - ); - } -} diff --git a/example/lib/main.dart b/example/lib/main.dart index d468537..ce72f3c 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,7 +1,53 @@ import 'package:flutter/material.dart'; - -import 'app.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:gettext_i18n/gettext_i18n.dart'; void main() { runApp(const MyApp()); } + +class MyApp extends StatelessWidget { + const MyApp({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: const HomePage(), + supportedLocales: ['en', 'fr', 'fr_CH'].map((l) => Locale(l)), + localizationsDelegates: [ + GettextLocalizationsDelegate(defaultLanguage: 'en'), + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + ], + localeListResolutionCallback: (locales, supportedLocales) { + if (locales != null) { + for (var locale in locales) { + var supportedLocale = supportedLocales.where((element) => + element.languageCode == locale.languageCode && + element.countryCode == locale.countryCode); + if (supportedLocale.isNotEmpty) { + return supportedLocale.first; + } + supportedLocale = supportedLocales.where( + (element) => element.languageCode == locale.languageCode); + if (supportedLocale.isNotEmpty) { + return supportedLocale.first; + } + } + } + return null; + }, + ); + } +} + +class HomePage extends StatelessWidget { + const HomePage({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Center( + child: Text(context.t('Hello, world !')), + ); + } +} diff --git a/pubspec.yaml b/pubspec.yaml index 2d43b19..253f061 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: gettext_i18n description: This package helps internationalizing a Flutter application. -version: 1.0.1 +version: 1.0.2 repository: https://github.com/frenchguych/gettext_i18n environment: