Skip to content

Commit

Permalink
Fixed : example
Browse files Browse the repository at this point in the history
  • Loading branch information
ymauray committed Nov 14, 2021
1 parent a5883d9 commit 8226292
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 56 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 1.0.2

* Fixed example

## 1.0.1

* Fixed packaging issues

## 1.0.0

* Initial release.
Expand Down
40 changes: 0 additions & 40 deletions example/lib/app.dart

This file was deleted.

13 changes: 0 additions & 13 deletions example/lib/home_page.dart

This file was deleted.

50 changes: 48 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -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 !')),
);
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit 8226292

Please sign in to comment.