diff --git a/covas_mobile/lib/classes/MyDrawer.dart b/covas_mobile/lib/classes/MyDrawer.dart index 8fea215..6272d76 100644 --- a/covas_mobile/lib/classes/MyDrawer.dart +++ b/covas_mobile/lib/classes/MyDrawer.dart @@ -15,6 +15,7 @@ import 'package:encrypt_shared_preferences/provider.dart'; import 'package:provider/provider.dart'; import '../locale_provider.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; class MyDrawer extends StatelessWidget with ShowAlertDialog { Future logout(BuildContext context) async { @@ -90,6 +91,8 @@ class MyDrawer extends StatelessWidget with ShowAlertDialog { @override Widget build(BuildContext context) { + final loc = AppLocalizations.of(context); + final localeProvider = Provider.of(context); return Drawer( child: ListView( padding: EdgeInsets.zero, @@ -110,7 +113,7 @@ class MyDrawer extends StatelessWidget with ShowAlertDialog { // Drawer Items ListTile( leading: Icon(Icons.home), - title: Text('Home'), + title: Text(loc?.home ?? "Home"), onTap: () { Navigator.pushReplacement( context, MaterialPageRoute(builder: (_) => ListItemMenu())); @@ -120,7 +123,7 @@ class MyDrawer extends StatelessWidget with ShowAlertDialog { ), ListTile( leading: Icon(Icons.settings), - title: Text('Settings'), + title: Text(loc?.settings ?? 'Settings'), onTap: () { Navigator.pushReplacement( context, @@ -130,7 +133,7 @@ class MyDrawer extends StatelessWidget with ShowAlertDialog { ), ListTile( leading: Icon(Icons.account_circle), - title: Text('Update profile'), + title: Text(loc?.update_profile ?? 'Update profile'), onTap: () { Navigator.pushReplacement( context, @@ -140,18 +143,18 @@ class MyDrawer extends StatelessWidget with ShowAlertDialog { ), ListTile( leading: Icon(Icons.language), - title: Text('Language'), + title: Text(loc?.language ?? 'Language'), onTap: () { showDialog( context: context, builder: (_) => AlertDialog( - title: Text('Select Language'), + title: Text(loc?.select_language ?? 'Select Language'), content: Column( mainAxisSize: MainAxisSize.min, children: [ ListTile( leading: Icon(Icons.flag), - title: Text('Français'), + title: Text(loc?.french ?? 'Français'), onTap: () { Provider.of(context, listen: false) .setLocale(const Locale('fr')); @@ -160,7 +163,7 @@ class MyDrawer extends StatelessWidget with ShowAlertDialog { ), ListTile( leading: Icon(Icons.flag_outlined), - title: Text('English'), + title: Text(loc?.english ?? 'English'), onTap: () { Provider.of(context, listen: false) .setLocale(const Locale('en')); @@ -176,15 +179,15 @@ class MyDrawer extends StatelessWidget with ShowAlertDialog { ListTile( leading: Icon(Icons.info), - title: Text('About'), + title: Text(loc?.about ?? 'About'), onTap: () { - showAlertDialog( - context, 'About', "Version 0.0.1"); // Close the drawer + showAlertDialog(context, loc?.about ?? 'About', + "Version 0.0.1"); // Close the drawer }, ), ListTile( leading: Icon(Icons.logout), - title: Text('Log out'), + title: Text(loc?.log_out ?? 'Log out'), onTap: () async { logout(context); // Close the drawer diff --git a/covas_mobile/lib/l10n/app_en.arb b/covas_mobile/lib/l10n/app_en.arb index a4abd5e..84846c5 100644 --- a/covas_mobile/lib/l10n/app_en.arb +++ b/covas_mobile/lib/l10n/app_en.arb @@ -1,4 +1,13 @@ { "@@locale": "en", -"menu_list": "Event list menu" +"menu_list": "Event list menu", +"language": "Language", +"home": "Home", +"settings": "Settings", +"update_profile": "Update profile", +"about": "About", +"log_out": "Log out", +"french": "French", +"english": "English", +"select_language": "Select language" } \ No newline at end of file diff --git a/covas_mobile/lib/l10n/app_fr.arb b/covas_mobile/lib/l10n/app_fr.arb index ca19c58..688bc22 100644 --- a/covas_mobile/lib/l10n/app_fr.arb +++ b/covas_mobile/lib/l10n/app_fr.arb @@ -1,4 +1,13 @@ { "@@locale": "fr", -"menu_list": "Liste d'évènement" +"menu_list": "Liste d'évènement", +"language": "Langue", +"home": "Accueil", +"settings": "Paramètres", +"update_profile": "Modifier profil", +"about": "À propos", +"log_out": "Se déconnecter", +"french": "Français", +"english": "Anglais", +"select_language": "Selectionne la langue" } \ No newline at end of file diff --git a/covas_mobile/lib/pages/ListItemMenu.dart b/covas_mobile/lib/pages/ListItemMenu.dart index 42bd752..0f42de4 100644 --- a/covas_mobile/lib/pages/ListItemMenu.dart +++ b/covas_mobile/lib/pages/ListItemMenu.dart @@ -864,8 +864,11 @@ class _MyHomePageState extends State { final startDate = DateTime.parse(post.startDate!); //final date = DateFormat.yMd().format(startDate); //final time = DateFormat.Hm().format(startDate); + final locale = + Provider.of(context).locale?.toString() ?? + 'en_US'; final dateLongue = - DateFormat('EEEE d MMMM y', 'fr_FR').format(startDate); + DateFormat('EEEE d MMMM y', locale).format(startDate); return ListTile( title: Text('${post.name!}'), subtitle: Text('${post.place!}\n${dateLongue}'),