diff --git a/assets/lang/ar.json b/assets/lang/ar.json deleted file mode 100644 index 4c8063b..0000000 --- a/assets/lang/ar.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "text_description": "مرحبًا ، سيتغير هذا النص وفقًا للغة" -} \ No newline at end of file diff --git a/assets/lang/en.json b/assets/lang/en.json index 0534439..1bb3ef5 100644 --- a/assets/lang/en.json +++ b/assets/lang/en.json @@ -1,5 +1,71 @@ { - "text_description": "Hello, this text will change according to the language", - "i18n_hello" : "Hello", - "i18n_take_pictures" : "Take pictures" + "i18n_label_ok":"OK", + "i18n_label_yes":"Yes", + "i18n_label_no":"No", + "i18n_label_cancel":"Cancel", + "i18n_label_delete":"Delete", + "i18n_label_hello":"Hello", + "i18n_label_take_photos":"Take photos", + "i18n_menu_settings":"Settings", + "i18n_menu_about":"About", + "i18n_menu_show_logs":"Show logs", + "i18n_menu_check_version":"Check version", + "i18n_menu_account":"Account", + "i18n_menu_notification":"Notification", + "i18n_label_sign_out":"Sign Out", + "i18n_label_photo_quality":"Photo quality", + "i18n_label_photo_resizing":"Photo resizing", + "i18n_label_sound_photo":"Play sound when taking photo", + "i18n_label_language":"Langage", + "i18n_label_copy_to_gallery":"Copy to gallery", + "i18n_label_edit_tag":"Edit tags", + "i18n_label_tags":"Tags", + "i18n_label_notag":"No tag", + "i18n_label_enter_tags":"Enter tag", + "i18n_label_competition":"Competition", + "i18n_label_choose_competitor":"Choose competitor", + "i18n_label_visibility":"Visibility", + "i18n_label_main_visibility":"Main", + "i18n_label_private_visibility":"Private", + "i18n_label_typology":"Typology", + "i18n_label_photo_added_to_gallery":"Photo has been added to gallery", + "i18n_label_image_rotated":"The image has been rotated", + "i18n_label_last_visit_access":"Last visit access", + "i18n_label_today_visits":"Today visits", + "i18n_label_previous_visits":"Previous visits", + "i18n_label_delete_photo":"Delete photo", + "i18n_label_confirm_delete_photo":"Are you sure you want to delete this photo ?", + "i18n_label_deleted_photo":"Photo has been deleted", + "i18n_label_data_synchronization":"Data synchronization", + "i18n_label_backoffice_synchronization":"Backoffice data synchronization", + "i18n_label_photos_synchronization":"Photos synchronization", + "i18n_label_sync_logs":"Sync logs", + "i18n_label_logs_synchronization":"Activity logs synchronization", + "i18n_label_confirmation":"Confirmation", + "i18n_label_confirm_delete_log":"Are you sure you want to delete logs ?", + "i18n_menu_check_update":"Checking for update", + "i18n_label_current_version":"Current version", + "i18n_label_available_version":"Available version", + "i18n_label_latest_version":"You have the latest version", + "i18n_label_release_notes":"Release notes", + "i18n_label_publication_date":"Publication date", + "i18n_label_update":"Update", + "i18n_label_choose_quality":"Choose quality", + "i18n_label_choose_language":"Choose language", + "i18n_label_synchronize":"Synchronize", + "i18n_label_new_version":"New version available", + "i18n_label_new_version_install":"A new version is available. Would you like to install it ?", + "i18n_label_never":"Never", + "i18n_label_no_internet":"No internet connection ...", + "i18n_menu_backoffice":"BackOffice", + "i18n_menu_photos":"Photos", + "i18n_menu_log":"Logs", + "i18n_label_photo_not_found":"Photo not found", + "i18n_label_photo":"Photo", + "i18n_label_save":"Save", + "i18n_label_error":"Error", + "i18n_label_app_version":"App Version", + "i18n_label_synchronization_error": "Synchronization error", + "i18n_label_synchronization_complete": "Synchronization complete", + "i18n_label_error_while_copying": "Error while copying" } \ No newline at end of file diff --git a/assets/lang/fr.json b/assets/lang/fr.json index c3ba4db..dd4efb0 100644 --- a/assets/lang/fr.json +++ b/assets/lang/fr.json @@ -1,4 +1,71 @@ { - "i18n_hello": "Bonjour", - "i18n_take_pictures" : "Prendre des photos" + "i18n_label_ok":"OK", + "i18n_label_yes":"Oui", + "i18n_label_no":"Non", + "i18n_label_cancel":"Annuler", + "i18n_label_delete":"Supprimer", + "i18n_label_hello":"Bonjour", + "i18n_label_take_photos":"Prendre des photos", + "i18n_menu_settings":"Paramètres", + "i18n_menu_about":"A propos", + "i18n_menu_show_logs":"Voir logs", + "i18n_menu_check_version":"Vérifier version", + "i18n_menu_account":"Profil", + "i18n_menu_notification":"Notification", + "i18n_label_sign_out":"Déconnecter", + "i18n_label_photo_quality":"Qualité photo", + "i18n_label_photo_resizing":"Redimensionnement photo", + "i18n_label_sound_photo":"Jouer son quand prise photo", + "i18n_label_language":"Langage", + "i18n_label_copy_to_gallery":"Copier dans galerie", + "i18n_label_edit_tag":"Modifier les tags", + "i18n_label_tags":"Tags", + "i18n_label_notag":"Aucun tag", + "i18n_label_enter_tags":"Saisir tag", + "i18n_label_competition":"Concurrence", + "i18n_label_choose_competitor":"Choisir concurrent", + "i18n_label_visibility":"Visibilité", + "i18n_label_main_visibility":"Principale", + "i18n_label_private_visibility":"Privée", + "i18n_label_typology":"Typologie", + "i18n_label_photo_added_to_gallery":"Photo ajoutée à la galerie", + "i18n_label_image_rotated":"Image retournée", + "i18n_label_last_visit_access":"Dernières visites", + "i18n_label_today_visits":"Visites du jour", + "i18n_label_previous_visits":"Visites précédentes", + "i18n_label_delete_photo":"Supprimer la photo", + "i18n_label_confirm_delete_photo":"Confirmez-vous la suppression de la photo ?", + "i18n_label_deleted_photo":"La photo a été supprimée", + "i18n_label_data_synchronization":"Synchronisation données", + "i18n_label_backoffice_synchronization":"Synchronisation des données du backoffice", + "i18n_label_photos_synchronization":"Synchronisation des photos", + "i18n_label_sync_logs":"Sync logs", + "i18n_label_logs_synchronization":"Synchronisation des journaux d'activité", + "i18n_label_confirmation":"Confirmation", + "i18n_label_confirm_delete_log":"Confirmez-vous la suppression des logs ?", + "i18n_menu_check_update":"Vérification mise à jour", + "i18n_label_current_version":"Version actuelle", + "i18n_label_available_version":"Version disponible", + "i18n_label_latest_version":"Vous avez la dernière version", + "i18n_label_release_notes":"Notes de mise à jour", + "i18n_label_publication_date":"Date de sortie", + "i18n_label_update":"Mettre à jour", + "i18n_label_choose_quality":"Choisir qualité", + "i18n_label_choose_language":"Choisir langage", + "i18n_label_synchronize":"Synchronisation", + "i18n_label_new_version":"Nouvelle version disponible", + "i18n_label_new_version_install": "Une nouvelle version est disponible. Voulez-vous l'installer ?", + "i18n_label_never":"Jamais", + "i18n_label_no_internet":"Aucune connexion internet ...", + "i18n_menu_backoffice":"BackOffice", + "i18n_menu_photos":"Photos", + "i18n_menu_log":"Logs", + "i18n_label_photo_not_found":"Photo introuvable", + "i18n_label_photo":"Photo", + "i18n_label_save":"Sauvegarder", + "i18n_label_error":"Erreur", + "i18n_label_app_version":"App Version", + "i18n_label_synchronization_error": "Erreur de synchronisation", + "i18n_label_synchronization_complete": "Synchronisation terminée", + "i18n_label_error_while_copying": "Erreur lors de la copie" } \ No newline at end of file diff --git a/assets/lang/hi.json b/assets/lang/hi.json deleted file mode 100644 index 542ad7d..0000000 --- a/assets/lang/hi.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "text_description": "नमस्कार, यह पाठ भाषा के अनुसार बदल जाएगा" -} \ No newline at end of file diff --git a/assets/lang/id.json b/assets/lang/id.json deleted file mode 100644 index 9e68159..0000000 --- a/assets/lang/id.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "text_description": "Halo, teks ini akan berubah menurut bahasanya" -} \ No newline at end of file diff --git a/assets/lang/th.json b/assets/lang/th.json deleted file mode 100644 index 0eca8e5..0000000 --- a/assets/lang/th.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "text_description": "สวัสดีข้อความนี้จะเปลี่ยนไปตามภาษา" -} \ No newline at end of file diff --git a/assets/lang/tk.json b/assets/lang/tk.json deleted file mode 100644 index 745b286..0000000 --- a/assets/lang/tk.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "text_description": "Merhaba, bu yazı dile göre değişecek" -} \ No newline at end of file diff --git a/assets/lang/zh.json b/assets/lang/zh.json deleted file mode 100644 index 4823aff..0000000 --- a/assets/lang/zh.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "text_description": "您好,该文字会根据语言而变化" -} \ No newline at end of file diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 48b9666..d594c58 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -20,7 +20,7 @@ PODS: - FMDB (2.7.5): - FMDB/standard (= 2.7.5) - FMDB/standard (2.7.5) - - image_gallery_saver (2.0.1): + - image_gallery_saver (2.0.2): - Flutter - image_picker_ios (0.0.1): - Flutter @@ -36,16 +36,16 @@ PODS: - Mantle (2.2.0): - Mantle/extobjc (= 2.2.0) - Mantle/extobjc (2.2.0) - - ObjectBox (1.8.1) + - ObjectBox (1.9.0) - objectbox_flutter_libs (0.0.1): - Flutter - - ObjectBox (= 1.8.1) + - ObjectBox (= 1.9.0) - package_info_plus (0.4.5): - Flutter - path_provider_foundation (0.0.1): - Flutter - FlutterMacOS - - permission_handler_apple (9.1.0): + - permission_handler_apple (9.1.1): - Flutter - ReachabilitySwift (5.0.0) - SDWebImage (5.16.0): @@ -57,11 +57,11 @@ PODS: - shared_preferences_foundation (0.0.1): - Flutter - FlutterMacOS - - sqflite (0.0.2): + - sqflite (0.0.3): - Flutter - FMDB (>= 2.7.5) - Toast (4.0.0) - - wakelock (0.0.1): + - wakelock_plus (0.0.1): - Flutter - webview_flutter_wkwebview (0.0.1): - Flutter @@ -82,7 +82,7 @@ DEPENDENCIES: - permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`) - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) - sqflite (from `.symlinks/plugins/sqflite/ios`) - - wakelock (from `.symlinks/plugins/wakelock/ios`) + - wakelock_plus (from `.symlinks/plugins/wakelock_plus/ios`) - webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/ios`) SPEC REPOS: @@ -127,38 +127,38 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/shared_preferences_foundation/darwin" sqflite: :path: ".symlinks/plugins/sqflite/ios" - wakelock: - :path: ".symlinks/plugins/wakelock/ios" + wakelock_plus: + :path: ".symlinks/plugins/wakelock_plus/ios" webview_flutter_wkwebview: :path: ".symlinks/plugins/webview_flutter_wkwebview/ios" SPEC CHECKSUMS: audioplayers_darwin: 877d9a4d06331c5c374595e46e16453ac7eafa40 camera_avfoundation: 3125e8cd1a4387f6f31c6c63abb8a55892a9eeeb - connectivity_plus: 07c49e96d7fc92bc9920617b83238c4d178b446a - device_info_plus: e5c5da33f982a436e103237c0c85f9031142abed + connectivity_plus: bf0076dd84a130856aa636df1c71ccaff908fa1d + device_info_plus: c6fb39579d0f423935b0c9ce7ee2f44b71b9fce6 Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 flutter_image_compress_common: ec1d45c362c9d30a3f6a0426c297f47c52007e3e - fluttertoast: eb263d302cc92e04176c053d2385237e9f43fad0 + fluttertoast: 31b00dabfa7fb7bacd9e7dbee580d7a2ff4bf265 FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a - image_gallery_saver: 6eb11e5a866e9ac2c8a98c74ef99a04fc62878b2 + image_gallery_saver: cb43cc43141711190510e92c460eb1655cd343cb image_picker_ios: 4a8aadfbb6dc30ad5141a2ce3832af9214a705b5 libwebp: f62cb61d0a484ba548448a4bd52aabf150ff6eef Mantle: c5aa8794a29a022dfbbfc9799af95f477a69b62d - ObjectBox: a7900d5335218cd437cbc080b7ccc38a5211f7b4 - objectbox_flutter_libs: 61d74196d924fbc773da5f5757d1e9fab7b3cc78 - package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e - path_provider_foundation: c68054786f1b4f3343858c1e1d0caaded73f0be9 - permission_handler_apple: 8f116445eff3c0e7c65ad60f5fef5490aa94b4e4 + ObjectBox: e7ff611291a0663380e0736b46786bcd077294ff + objectbox_flutter_libs: 0948d6feb7de4f7edaebc7a898b9e85b7fc2bc89 + package_info_plus: 115f4ad11e0698c8c1c5d8a689390df880f47e85 + path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943 + permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6 ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825 SDWebImage: 2aea163b50bfcb569a2726b6a754c54a4506fcf6 SDWebImageWebPCoder: 295a6573c512f54ad2dd58098e64e17dcf008499 - shared_preferences_foundation: 986fc17f3d3251412d18b0265f9c64113a8c2472 - sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904 + shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126 + sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a Toast: 91b396c56ee72a5790816f40d3a94dd357abc196 - wakelock: d0fc7c864128eac40eba1617cb5264d9c940b46f + wakelock_plus: 8b09852c8876491e4b6d179e17dfe2a0b5f60d47 webview_flutter_wkwebview: 2e2d318f21a5e036e2c3f26171342e95908bd60a PODFILE CHECKSUM: b634fd49380cdd3837626153fb977533b1916433 -COCOAPODS: 1.11.3 +COCOAPODS: 1.14.3 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 59029e7..77b2661 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -156,7 +156,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1430; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { diff --git a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index c87d15a..a6b826d 100644 --- a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ { @override bool isSupported(Locale locale) { // Include all of your supported language codes here - return ['fr', 'en', 'id', 'ar', 'zh', 'hi', 'th', 'tk'] - .contains(locale.languageCode); + return ['fr', 'en'].contains(locale.languageCode); } @override Future load(Locale locale) async { - final SharedPreferences _pref = await SharedPreferences.getInstance(); - String? lCode = _pref.getString('lCode'); - String? cCode = _pref.getString('cCode'); + locale = SharedPrefs().language; - if (lCode == null || cCode == null) { - await _pref.setString('lCode', locale.languageCode); - await _pref.setString('cCode', locale.countryCode!); - } else { - locale = Locale(lCode, cCode); - } AppLocalizations localizations = new AppLocalizations(locale); + await localizations.load(); + return localizations; } diff --git a/lib/events.dart b/lib/events.dart index 6fca52e..f8ebff7 100644 --- a/lib/events.dart +++ b/lib/events.dart @@ -36,3 +36,12 @@ class SynchronizationEvent extends AppEvent { @override List get props => [isRunning]; } + +class ChangeLocaleEvent extends AppEvent { + ChangeLocaleEvent(this.language); + + final String language; + + @override + List get props => [language]; +} diff --git a/lib/main.dart b/lib/main.dart index ad1ef16..be26e98 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -165,16 +165,7 @@ class MyApp extends StatelessWidget with WidgetsBindingObserver { }), ), // below is used for language feature - supportedLocales: [ - Locale('fr', 'FR'), - Locale('en', 'US'), - Locale('id', 'ID'), - Locale('ar', 'DZ'), - Locale('zh', 'HK'), - Locale('hi', 'IN'), - Locale('th', 'TH'), - Locale('tk', 'TK'), - ], + supportedLocales: [Locale('fr', 'FR'), Locale('en', 'US')], // These delegates make sure that the localization data for the proper language is loaded localizationsDelegates: [ AppLocalizationsDelegate(), diff --git a/lib/model/visit_model.dart b/lib/model/visit_model.dart index a9bc951..6434eb2 100644 --- a/lib/model/visit_model.dart +++ b/lib/model/visit_model.dart @@ -1,5 +1,6 @@ import 'package:intl/intl.dart'; import 'package:mobdr/main.dart'; +import 'package:mobdr/service/shared_prefs.dart'; class VisitModel { late int id; @@ -31,7 +32,6 @@ class VisitModel { static Future> getTodayVisits() async { // Retrieve all today visits from the database final visits = await objectbox.getTodayVisit(); - // Map each retrieved visit to VisiteModel final visitModelList = visits .map((visite) => VisitModel( @@ -41,7 +41,7 @@ class VisitModel { id_visite: visite.id_visite, name: visite.id_etab.toString() + ' - ' + visite.title, photoCount: objectbox.getVisitPhotoTaken(visite.id_visite), - date: DateFormat('EEEE d MMMM HH:mm', 'fr_FR') + date: DateFormat('EEEE d MMMM HH:mm', SharedPrefs().locale) .format(visite.date_visite), image: visite.url_photo_principale, type_visite: visite.type_visite, @@ -66,7 +66,7 @@ class VisitModel { id_visite: visite.id_visite, name: visite.id_etab.toString() + ' - ' + visite.title, photoCount: objectbox.getVisitPhotoTaken(visite.id_visite), - date: DateFormat('EEEE d MMMM HH:mm', 'fr_FR') + date: DateFormat('EEEE d MMMM HH:mm', SharedPrefs().locale) .format(visite.date_visite), image: visite.url_photo_principale, type_visite: visite.type_visite, @@ -91,7 +91,7 @@ class VisitModel { id_visite: visite.id_visite, name: visite.id_etab.toString() + ' - ' + visite.title, photoCount: objectbox.getVisitPhotoTaken(visite.id_visite), - date: DateFormat('EEEE d MMMM HH:mm', 'fr_FR') + date: DateFormat('EEEE d MMMM HH:mm', SharedPrefs().locale) .format(visite.date_visite), image: visite.url_photo_principale, type_visite: visite.type_visite, diff --git a/lib/service/shared_prefs.dart b/lib/service/shared_prefs.dart index 0f563c5..8e10f19 100644 --- a/lib/service/shared_prefs.dart +++ b/lib/service/shared_prefs.dart @@ -1,4 +1,5 @@ import 'package:shared_preferences/shared_preferences.dart'; +import 'package:flutter/material.dart'; class SharedPrefs { static late SharedPreferences _sharedPrefs; @@ -241,4 +242,24 @@ class SharedPrefs { set systemVersion(String value) { _sharedPrefs.setString('key_system_version', value); } + + /// get/set language code + String get lCode => _sharedPrefs.getString('lcode') ?? "fr"; + + set lCode(String value) { + _sharedPrefs.setString('lcode', value); + } + + /// get/set language country code + String get cCode => _sharedPrefs.getString('ccode') ?? "FR"; + + set cCode(String value) { + _sharedPrefs.setString('ccode', value); + } + + /// get language object + Locale get language => Locale(lCode, cCode); + + /// get locale object + String get locale => lCode + "_" + cCode; } diff --git a/lib/ui/account/about.dart b/lib/ui/account/about.dart index 0ad8848..0ec6374 100644 --- a/lib/ui/account/about.dart +++ b/lib/ui/account/about.dart @@ -1,3 +1,4 @@ +import 'package:mobdr/cubit/language/app_localizations.dart'; import 'package:mobdr/config/constant.dart'; import 'package:mobdr/config/global_style.dart'; import 'package:mobdr/service/shared_prefs.dart'; @@ -27,7 +28,7 @@ class _AboutPageState extends State { ), elevation: GlobalStyle.appBarElevation, title: Text( - 'About', + AppLocalizations.of(context)!.translate('i18n_menu_about'), style: GlobalStyle.appBarTitle, ), backgroundColor: GlobalStyle.appBarBackgroundColor, @@ -44,7 +45,7 @@ class _AboutPageState extends State { height: 50, ), Text( - 'App Version', + AppLocalizations.of(context)!.translate('i18n_label_app_version'), style: TextStyle(fontSize: 14, color: CHARCOAL), ), SizedBox( diff --git a/lib/ui/account/log.dart b/lib/ui/account/log.dart index 7664101..b4ad07f 100644 --- a/lib/ui/account/log.dart +++ b/lib/ui/account/log.dart @@ -6,6 +6,7 @@ import 'package:mobdr/ui/reusable/reusable_widget.dart'; import 'package:mobdr/db/box_log.dart'; import 'package:mobdr/service/plausible.dart'; import 'package:mobdr/service/logger_util.dart'; +import 'package:mobdr/cubit/language/app_localizations.dart'; class LogPage extends StatefulWidget { @override @@ -89,17 +90,19 @@ class _LogPageState extends State { showDialog( context: context, builder: (context) => AlertDialog( - title: Text('Confirmation'), - content: Text('Are you sure you want to delete these logs ?'), + title: Text( + AppLocalizations.of(context)!.translate('i18n_label_confirmation')), + content: Text( + AppLocalizations.of(context)!.translate('i18n_label_confirm_delete_log')), actions: [ TextButton( - child: Text('Cancel'), + child: Text(AppLocalizations.of(context)!.translate('i18n_label_cancel')), onPressed: () { Navigator.of(context).pop(); }, ), TextButton( - child: Text('Delete'), + child: Text(AppLocalizations.of(context)!.translate('i18n_label_delete')), onPressed: () { // remove all log from db objectbox.logBox.removeAll(); @@ -123,7 +126,7 @@ class _LogPageState extends State { ), elevation: GlobalStyle.appBarElevation, title: Text( - 'Show logs', + AppLocalizations.of(context)!.translate('i18n_menu_show_logs'), style: GlobalStyle.appBarTitle, ), backgroundColor: GlobalStyle.appBarBackgroundColor, diff --git a/lib/ui/account/settings.dart b/lib/ui/account/settings.dart index 5ecdf9e..8f81f7a 100644 --- a/lib/ui/account/settings.dart +++ b/lib/ui/account/settings.dart @@ -2,10 +2,13 @@ import 'package:flutter/material.dart'; import 'package:mobdr/config/constant.dart'; import 'package:mobdr/config/global_style.dart'; +import 'package:mobdr/main.dart'; +import 'package:mobdr/cubit/language/app_localizations.dart'; import 'package:mobdr/ui/reusable/reusable_widget.dart'; import 'package:mobdr/service/shared_prefs.dart'; import 'package:mobdr/service/plausible.dart'; import 'package:mobdr/service/logger_util.dart'; +import 'package:mobdr/events.dart'; class SettingsPage extends StatefulWidget { @override @@ -63,7 +66,7 @@ class _SettingsPageState extends State { ), elevation: GlobalStyle.appBarElevation, title: Text( - 'Settings', + AppLocalizations.of(context)!.translate('i18n_menu_settings'), style: GlobalStyle.appBarTitle, ), backgroundColor: GlobalStyle.appBarBackgroundColor, @@ -100,7 +103,9 @@ class _SettingsPageState extends State { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text('Photo quality', + Text( + AppLocalizations.of(context)! + .translate('i18n_label_photo_quality'), style: TextStyle(fontSize: 15, color: CHARCOAL)), Row( children: [ @@ -127,7 +132,8 @@ class _SettingsPageState extends State { child: SwitchListTile( contentPadding: EdgeInsets.zero, title: Text( - 'Photo resizing', + AppLocalizations.of(context)! + .translate('i18n_label_photo_resizing'), style: TextStyle(fontSize: 15, color: CHARCOAL), ), value: _photoResizing, @@ -146,7 +152,8 @@ class _SettingsPageState extends State { child: SwitchListTile( contentPadding: EdgeInsets.zero, title: Text( - 'Play sound when taking a photo', + AppLocalizations.of(context)! + .translate('i18n_label_sound_photo'), style: TextStyle(fontSize: 15, color: CHARCOAL), ), value: _photoSound, @@ -183,7 +190,10 @@ class _SettingsPageState extends State { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text('Language', style: TextStyle(fontSize: 15, color: CHARCOAL)), + Text( + AppLocalizations.of(context)! + .translate('i18n_label_language'), + style: TextStyle(fontSize: 15, color: CHARCOAL)), Row( children: [ Text( @@ -235,7 +245,8 @@ class _SettingsPageState extends State { Container( margin: EdgeInsets.fromLTRB(16, 8, 16, 8), child: Text( - 'Choose Quality', + AppLocalizations.of(context)! + .translate('i18n_label_choose_quality'), style: GlobalStyle.chooseCourier, ), ), @@ -253,7 +264,8 @@ class _SettingsPageState extends State { onChanged: (String? value) { setState(() { _photoQuality = value!; - SharedPrefs().photoQuality = value; + SharedPrefs().photoQuality = + value; // TODO : Passer par un numéro plutot qu'une chaine qui sera traduite ... }); Navigator.pop(context); }, @@ -289,7 +301,8 @@ class _SettingsPageState extends State { Container( margin: EdgeInsets.fromLTRB(16, 8, 16, 8), child: Text( - 'Choose Language', + AppLocalizations.of(context)! + .translate('i18n_label_choose_language'), style: GlobalStyle.chooseCourier, ), ), @@ -309,12 +322,15 @@ class _SettingsPageState extends State { onChanged: (String? value) { setState(() { _language = value!; + switch (value) { case 'English': SharedPrefs().langage = 'en'; + eventBus.fire(ChangeLocaleEvent('en')); break; case 'French': SharedPrefs().langage = 'fr'; + eventBus.fire(ChangeLocaleEvent('fr')); break; default: _language = 'French'; diff --git a/lib/ui/account/tab_account.dart b/lib/ui/account/tab_account.dart index fae6cf8..671ad32 100644 --- a/lib/ui/account/tab_account.dart +++ b/lib/ui/account/tab_account.dart @@ -16,6 +16,7 @@ import 'package:flutter/material.dart'; import 'package:mobdr/ui/authentication/signin.dart'; import 'dart:convert'; import 'package:mobdr/main.dart'; +import 'package:mobdr/cubit/language/app_localizations.dart'; class TabAccountPage extends StatefulWidget { @override @@ -51,7 +52,7 @@ class _TabAccountPageState extends State ), elevation: GlobalStyle.appBarElevation, title: Text( - 'Account', + AppLocalizations.of(context)!.translate('i18n_menu_account'), style: GlobalStyle.appBarTitle, ), backgroundColor: GlobalStyle.appBarBackgroundColor, @@ -73,13 +74,22 @@ class _TabAccountPageState extends State padding: EdgeInsets.all(16), children: [ _createAccountInformation(), - _createListMenu('Settings', SettingsPage()), + _createListMenu( + AppLocalizations.of(context)!.translate('i18n_menu_settings'), + SettingsPage()), _reusableWidget.divider1(), - _createListMenu('About', AboutPage()), + _createListMenu( + AppLocalizations.of(context)!.translate('i18n_menu_about'), + AboutPage()), _reusableWidget.divider1(), - _createListMenu('Show logs', LogPage()), + _createListMenu( + AppLocalizations.of(context)!.translate('i18n_menu_show_logs'), + LogPage()), _reusableWidget.divider1(), - _createListMenu('Check version', UpdateCheckPage()), + _createListMenu( + AppLocalizations.of(context)! + .translate('i18n_menu_check_version'), + UpdateCheckPage()), _reusableWidget.divider1(), Container( margin: EdgeInsets.fromLTRB(0, 18, 0, 0), @@ -111,7 +121,9 @@ class _TabAccountPageState extends State Icon(Icons.power_settings_new, size: 20, color: ASSENT_COLOR), SizedBox(width: 8), - Text('Sign Out', + Text( + AppLocalizations.of(context)! + .translate('i18n_label_sign_out'), style: TextStyle(fontSize: 15, color: ASSENT_COLOR)), ], ), diff --git a/lib/ui/appstore/updatecheck.dart b/lib/ui/appstore/updatecheck.dart index 9e4ea75..b552b2e 100644 --- a/lib/ui/appstore/updatecheck.dart +++ b/lib/ui/appstore/updatecheck.dart @@ -5,6 +5,7 @@ import 'package:http/http.dart' as http; import 'package:mobdr/service/shared_prefs.dart'; import 'package:mobdr/config/constant.dart'; +import 'package:mobdr/cubit/language/app_localizations.dart'; class UpdateCheckPage extends StatefulWidget { @override @@ -69,7 +70,8 @@ class _UpdateCheckPageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('Checking for update'), + title: Text(AppLocalizations.of(context)! + .translate('i18n_menu_check_update')), ), body: Center( child: currentEvent == null @@ -77,7 +79,8 @@ class _UpdateCheckPageState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Text( - 'Current version : ', + AppLocalizations.of(context)! + .translate('i18n_label_current_version'), style: TextStyle( fontWeight: FontWeight.bold, fontSize: 16, @@ -93,7 +96,8 @@ class _UpdateCheckPageState extends State { ), SizedBox(height: 16), Text( - 'Version available : ', + AppLocalizations.of(context)! + .translate('i18n_label_available_version'), style: TextStyle( fontWeight: FontWeight.bold, fontSize: 18, @@ -110,12 +114,13 @@ class _UpdateCheckPageState extends State { if (_currentVersion != _latestVersion) ...[ SizedBox(height: 16), Text( - 'Publication date : $_releaseDate', + '${AppLocalizations.of(context)!.translate('i18n_label_publication_date')} : $_releaseDate', style: TextStyle(fontWeight: FontWeight.bold), ), SizedBox(height: 8), Text( - 'Release notes :', + AppLocalizations.of(context)! + .translate('i18n_label_release_notes') + ' :', style: TextStyle(fontWeight: FontWeight.bold), ), for (String note in _releaseNotes) ...[ @@ -126,7 +131,8 @@ class _UpdateCheckPageState extends State { ElevatedButton( onPressed: _doUpdate, child: Text( - 'Update', + AppLocalizations.of(context)! + .translate('i18n_label_update'), style: TextStyle( fontWeight: FontWeight.bold, fontSize: 18, @@ -139,7 +145,8 @@ class _UpdateCheckPageState extends State { ] else ...[ SizedBox(height: 32), Text( - 'You have the latest version', + AppLocalizations.of(context)! + .translate('i18n_label_latest_version'), style: TextStyle( fontWeight: FontWeight.bold, fontSize: 18, diff --git a/lib/ui/general/notification.dart b/lib/ui/general/notification.dart index 8725bc9..11f3cff 100644 --- a/lib/ui/general/notification.dart +++ b/lib/ui/general/notification.dart @@ -6,6 +6,7 @@ import 'package:mobdr/config/global_style.dart'; import 'package:mobdr/ui/reusable/reusable_widget.dart'; import 'package:mobdr/service/plausible.dart'; import 'package:mobdr/service/logger_util.dart'; +import 'package:mobdr/cubit/language/app_localizations.dart'; class NotificationPage extends StatefulWidget { @override @@ -39,8 +40,7 @@ class _NotificationPageState extends State { color: GlobalStyle.appBarIconThemeColor, ), elevation: GlobalStyle.appBarElevation, - title: Text( - 'Notification', + title: Text(AppLocalizations.of(context)!.translate('i18n_menu_notification'), style: GlobalStyle.appBarTitle, ), backgroundColor: GlobalStyle.appBarBackgroundColor, diff --git a/lib/ui/home.dart b/lib/ui/home.dart index 78ec950..2799ee8 100644 --- a/lib/ui/home.dart +++ b/lib/ui/home.dart @@ -11,6 +11,7 @@ import 'package:mobdr/config/constant.dart'; import 'package:mobdr/events.dart'; import 'package:mobdr/service/plausible.dart'; import 'package:mobdr/service/logger_util.dart'; +import 'package:mobdr/cubit/language/app_localizations.dart'; class HomePage extends StatefulWidget { @override @@ -144,7 +145,7 @@ class _HomePageState extends State icon: Icon(Icons.web), ), BottomNavigationBarItem( - label: 'Account', + label: AppLocalizations.of(context)!.translate('i18n_menu_account'), icon: Icon(Icons.person_outline), ), ], diff --git a/lib/ui/home/tab_home.dart b/lib/ui/home/tab_home.dart index a808e09..0949b57 100644 --- a/lib/ui/home/tab_home.dart +++ b/lib/ui/home/tab_home.dart @@ -8,7 +8,6 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; -import 'package:shared_preferences/shared_preferences.dart'; import 'package:badges/badges.dart' as badges; import 'package:mobdr/main.dart'; @@ -39,13 +38,12 @@ class _TabHomePageState extends State late StreamSubscription subVisitPhotoCountEvent; late StreamSubscription subRefreshCalendarEvent; + late StreamSubscription subChangeLocaleEvent; // keep the state to do not refresh when switch navbar @override bool get wantKeepAlive => true; - String defaultLang = 'en'; - DateTime _todayDate = DateTime.now(); late LanguageCubit _languageCubit; @@ -60,12 +58,6 @@ class _TabHomePageState extends State _languageCubit = BlocProvider.of(context); - _getLocale().then((val) { - setState(() { - defaultLang = val!; - }); - }); - loadData().then((_) { setState(() { // Listen refresh photo count event @@ -97,6 +89,26 @@ class _TabHomePageState extends State loadData(); }); }); + + // Listen change locale event + subChangeLocaleEvent = eventBus.on().listen((e) { + setState(() { + switch (e.language) { + case 'en': + SharedPrefs().lCode = 'en'; + SharedPrefs().cCode = 'US'; + _languageCubit.changeLanguage(SharedPrefs().language); + break; + case 'fr': + SharedPrefs().lCode = 'fr'; + SharedPrefs().cCode = 'FR'; + _languageCubit.changeLanguage(SharedPrefs().language); + break; + } + + loadData(); + }); + }); }); } @@ -104,30 +116,17 @@ class _TabHomePageState extends State void dispose() { subRefreshCalendarEvent.cancel(); subVisitPhotoCountEvent.cancel(); + subChangeLocaleEvent.cancel(); super.dispose(); } - Future _getLocale() async { - final SharedPreferences _pref = await SharedPreferences.getInstance(); - String? lCode = _pref.getString('lCode'); - return lCode; - } - - void changeLocale(Locale locale) async { - final SharedPreferences _pref = await SharedPreferences.getInstance(); - await _pref.setString('lCode', locale.languageCode); - await _pref.setString('cCode', locale.countryCode!); - _languageCubit.changeLanguage(locale); - defaultLang = locale.languageCode; - } - @override Widget build(BuildContext context) { // if we used AutomaticKeepAliveClientMixin, we must call super.build(context); super.build(context); final double boxImageSize = (MediaQuery.of(context).size.width / 3); final formattedDate = - DateFormat('EEEE d MMMM y', 'fr_FR').format(_todayDate); + DateFormat('EEEE d MMMM y', SharedPrefs().locale).format(_todayDate); return Scaffold( appBar: AppBar( @@ -136,7 +135,7 @@ class _TabHomePageState extends State title: Align( alignment: Alignment.centerLeft, child: Text( - AppLocalizations.of(context)!.translate('i18n_hello')! + + AppLocalizations.of(context)!.translate('i18n_label_hello') + ', ${SharedPrefs().prenom}', style: GlobalStyle.appBarTitle, ), @@ -194,7 +193,9 @@ class _TabHomePageState extends State padding: EdgeInsets.fromLTRB(16, 8, 0, 0), child: Row( children: [ - Text('Last visit access', style: GlobalStyle.horizontalTitle), + Text( + AppLocalizations.of(context)! + .translate('i18n_label_last_visit_access'), style: GlobalStyle.horizontalTitle), ], ), ), @@ -215,7 +216,9 @@ class _TabHomePageState extends State padding: EdgeInsets.fromLTRB(16, 16, 16, 0), child: Row( children: [ - Text('Today Visits', style: GlobalStyle.horizontalTitle), + Text( + AppLocalizations.of(context)! + .translate('i18n_label_today_visits'), style: GlobalStyle.horizontalTitle), Container( child: Padding( padding: const EdgeInsets.symmetric( @@ -248,7 +251,8 @@ class _TabHomePageState extends State mainAxisAlignment: MainAxisAlignment.center, children: [ Text( - 'Synchronize', + AppLocalizations.of(context)! + .translate('i18n_label_synchronize'), style: TextStyle( color: Colors.blue, fontSize: 16, @@ -290,7 +294,7 @@ class _TabHomePageState extends State child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text('Previous Visits', style: GlobalStyle.horizontalTitle), + Text(AppLocalizations.of(context)!.translate('i18n_label_previous_visits'), style: GlobalStyle.horizontalTitle), ], ), ), diff --git a/lib/ui/onboarding.dart b/lib/ui/onboarding.dart index cfde80c..f341f16 100644 --- a/lib/ui/onboarding.dart +++ b/lib/ui/onboarding.dart @@ -34,8 +34,8 @@ class _OnBoardingPageState extends State { PageModel( color: Colors.white, imageFromUrl: GLOBAL_IMAGES_URL + '/onboarding-synchro.png', - title: 'MP4 synchronisation', - body: 'Synchronise your data quickly and easily with MP4 :)', + title: 'MP4 synchronization', + body: 'Synchronize your data quickly and easily with MP4 :)', doAnimateImage: true), PageModel( color: Colors.white, diff --git a/lib/ui/sync/tab_synchro.dart b/lib/ui/sync/tab_synchro.dart index fd722b5..e0d787d 100644 --- a/lib/ui/sync/tab_synchro.dart +++ b/lib/ui/sync/tab_synchro.dart @@ -13,6 +13,7 @@ import 'package:mobdr/service/shared_prefs.dart'; import 'package:mobdr/network/api_provider.dart'; import 'package:mobdr/db/box_visit_photo.dart'; import 'package:mobdr/service/logger_util.dart'; +import 'package:mobdr/cubit/language/app_localizations.dart'; class SynchronizationPage extends StatefulWidget { @override @@ -83,18 +84,18 @@ class _SynchronizationPageState extends State context: context, builder: (BuildContext context) { return AlertDialog( - title: Text("New version available"), - content: Text( - "A new version is available. Would you like to install it?"), + title: Text(AppLocalizations.of(context)!.translate('i18n_label_new_version')), + content: Text(AppLocalizations.of(context)!.translate('i18n_label_new_version_install')), actions: [ TextButton( - child: Text("No"), + child: Text(AppLocalizations.of(context)!.translate('i18n_label_no')), onPressed: () { Navigator.pop(context); // Closes the dialog box }, ), TextButton( - child: Text("Yes"), + child: Text(AppLocalizations.of(context)! + .translate('i18n_label_yes')), onPressed: () { Navigator.pop(context); // Closes the dialog box Navigator.push( @@ -330,7 +331,7 @@ class _SynchronizationPageState extends State ), elevation: GlobalStyle.appBarElevation, title: Text( - 'Data synchronization', + AppLocalizations.of(context)!.translate('i18n_label_data_synchronization'), style: GlobalStyle.appBarTitle, ), backgroundColor: GlobalStyle.appBarBackgroundColor, @@ -378,10 +379,11 @@ class _SynchronizationPageState extends State SizedBox(height: 10), Text( !_isInternetConnexion - ? "No internet connection ..." + ? AppLocalizations.of(context)! + .translate('i18n_label_no_internet') : (SharedPrefs().lastCalendarRefresh.isNotEmpty ? SharedPrefs().lastCalendarRefresh - : "Never"), + : AppLocalizations.of(context)!.translate('i18n_label_never')), style: TextStyle( fontSize: 16, color: !_isInternetConnexion @@ -397,7 +399,7 @@ class _SynchronizationPageState extends State mainAxisAlignment: MainAxisAlignment.end, children: [ Text( - 'Sync Logs', + AppLocalizations.of(context)!.translate('i18n_label_sync_logs'), style: TextStyle(fontSize: 16), ), Switch( @@ -413,8 +415,9 @@ class _SynchronizationPageState extends State SizedBox(height: 20), SyncItem( icon: Icons.business, - title: 'Backoffice', - description: 'Synchronisation des données du backoffice', + title: AppLocalizations.of(context)!.translate('i18n_menu_backoffice'), + description: AppLocalizations.of(context)! + .translate('i18n_label_backoffice_synchronization'), isSyncing: _isSyncing, syncCompleted: _syncCompleted, isError: _syncCompleted && !_backofficeSyncCompleted, @@ -422,8 +425,9 @@ class _SynchronizationPageState extends State SizedBox(height: 20), SyncItem( icon: Icons.photo, - title: 'Photos', - description: 'Synchronisation des photos', + title: AppLocalizations.of(context)!.translate('i18n_menu_photos'), + description: AppLocalizations.of(context)! + .translate('i18n_label_photos_synchronization'), isSyncing: _isSyncing, syncCompleted: _syncCompleted, isError: _syncCompleted && !_photosSyncCompleted, @@ -431,8 +435,9 @@ class _SynchronizationPageState extends State SizedBox(height: 20), SyncItem( icon: Icons.warning, - title: 'Log', - description: 'Synchronisation des journaux d\'activité', + title: AppLocalizations.of(context)!.translate('i18n_menu_log'), + description: AppLocalizations.of(context)! + .translate('i18n_label_logs_synchronization'), isSyncing: _isSyncing, syncCompleted: _syncCompleted, isError: _syncCompleted && !_logSyncCompleted, @@ -500,8 +505,10 @@ class SyncItem extends StatelessWidget { SizedBox(width: 10), Text( isError - ? 'Erreur de synchronisation' - : 'Synchronisation terminée', + ? AppLocalizations.of(context)! + .translate('i18n_label_synchronization_error') + : AppLocalizations.of(context)! + .translate('i18n_label_synchronization_complete'), style: TextStyle( color: isError ? Colors.red : Colors.green, fontWeight: FontWeight.bold, diff --git a/lib/ui/visit/visit_photo_tag.dart b/lib/ui/visit/visit_photo_tag.dart index 892caa8..787e61a 100644 --- a/lib/ui/visit/visit_photo_tag.dart +++ b/lib/ui/visit/visit_photo_tag.dart @@ -7,6 +7,7 @@ import 'package:mobdr/ui/reusable/reusable_widget.dart'; import 'package:super_tag_editor/tag_editor.dart'; import 'package:super_tag_editor/widgets/rich_text_widget.dart'; +import 'package:mobdr/cubit/language/app_localizations.dart'; class PhotoTagPage extends StatefulWidget { // variables corresponding to the data parameters @@ -70,7 +71,8 @@ class _PhotoTagPageState extends State { ), elevation: GlobalStyle.appBarElevation, title: Text( - 'Edit tags ...', + AppLocalizations.of(context)!.translate('i18n_label_edit_tag') + + ' ...', style: GlobalStyle.appBarTitle, ), backgroundColor: GlobalStyle.appBarBackgroundColor, @@ -96,9 +98,9 @@ class _PhotoTagPageState extends State { _selectedTags.add(outstandingValue); }); }, - inputDecoration: const InputDecoration( + inputDecoration: InputDecoration( border: InputBorder.none, - hintText: 'Enter tag ...', + hintText: AppLocalizations.of(context)!.translate('i18n_label_enter_tags') + ' ...', ), onTagChanged: (newValue) { setState(() { @@ -204,7 +206,8 @@ class _PhotoTagPageState extends State { Navigator.pop( context, _selectedTags.map((tag) => tag).toList()); }, - child: const Text('Save'), + child: new Text( + AppLocalizations.of(context)!.translate('i18n_label_save')), ), ], ), diff --git a/lib/ui/visit/visit_photo_typology_detail.dart b/lib/ui/visit/visit_photo_typology_detail.dart index e536251..6a29241 100644 --- a/lib/ui/visit/visit_photo_typology_detail.dart +++ b/lib/ui/visit/visit_photo_typology_detail.dart @@ -19,6 +19,7 @@ import 'package:mobdr/db/box_photo_competitor.dart'; import 'package:mobdr/model/visit_model.dart'; import 'package:mobdr/service/plausible.dart'; import 'package:mobdr/service/logger_util.dart'; +import 'package:mobdr/cubit/language/app_localizations.dart'; class VisitPhotoTypologyDetailPage extends StatefulWidget { final VisitModel pp_visitModel; @@ -124,11 +125,11 @@ class _VisitPhotoTypologyDetailPageState } else if (_errorMessage.isNotEmpty) { return Center( child: AlertDialog( - title: Text("Erreur"), - content: Text("La photo est introuvable"), + title: Text(AppLocalizations.of(context)!.translate('i18n_label_error')), + content: Text(AppLocalizations.of(context)!.translate('i18n_label_photo_not_found')), actions: [ TextButton( - child: Text("OK"), + child: Text(AppLocalizations.of(context)!.translate('i18n_label_ok')), onPressed: () { Navigator.of(context).pop(); }, @@ -144,7 +145,7 @@ class _VisitPhotoTypologyDetailPageState ), elevation: GlobalStyle.appBarElevation, title: Text( - 'Photo', + AppLocalizations.of(context)!.translate('i18n_label_photo'), style: GlobalStyle.appBarTitle, ), backgroundColor: GlobalStyle.appBarBackgroundColor, @@ -211,7 +212,7 @@ class _VisitPhotoTypologyDetailPageState 'LOG', 'MOBDR', 'Copier dans galerie', 0); Fluttertoast.showToast( - msg: 'Photo has been added to gallery', + msg: AppLocalizations.of(context)!.translate('i18n_label_photo_added_to_gallery'), toastLength: Toast.LENGTH_LONG); } else { // log tracker @@ -219,7 +220,7 @@ class _VisitPhotoTypologyDetailPageState 'Erreur copier dans galerie', 0); Fluttertoast.showToast( - msg: 'Error while copying!', + msg: AppLocalizations.of(context)!.translate('i18n_label_error_while_copying'), toastLength: Toast.LENGTH_LONG); } }, @@ -233,7 +234,9 @@ class _VisitPhotoTypologyDetailPageState borderRadius: BorderRadius.all(Radius.circular( 10) // <--- border radius here )), - child: Text('Copier dans galerie', + child: Text( + AppLocalizations.of(context)! + .translate('i18n_label_copy_to_gallery'), style: TextStyle( color: SOFT_BLUE, fontWeight: FontWeight.bold)), @@ -295,7 +298,9 @@ class _VisitPhotoTypologyDetailPageState child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text('Typologie', style: GlobalStyle.sectionTitle), + Text( + AppLocalizations.of(context)! + .translate('i18n_label_typology'), style: GlobalStyle.sectionTitle), SizedBox( height: 16, ), @@ -402,16 +407,18 @@ class _VisitPhotoTypologyDetailPageState children: [ Row( children: [ - Text('Visibility', style: GlobalStyle.sectionTitle), + Text(AppLocalizations.of(context)!.translate('i18n_label_visibility'), style: GlobalStyle.sectionTitle), ], ), SizedBox(height: 16), - _checkboxVisibility(value: 'private', primaryText: 'Privée'), + _checkboxVisibility(value: 'private', primaryText: AppLocalizations.of(context)! + .translate('i18n_label_private_visibility')), Divider( height: 32, color: Colors.grey[400], ), - _checkboxVisibility(value: 'principal', primaryText: 'Principale') + _checkboxVisibility(value: 'principal', primaryText: AppLocalizations.of(context)! + .translate('i18n_label_main_visibility')) ], ), ); @@ -448,7 +455,8 @@ class _VisitPhotoTypologyDetailPageState children: [ Row( children: [ - Text('Tags', style: GlobalStyle.sectionTitle), + Text(AppLocalizations.of(context)! + .translate('i18n_label_tags'), style: GlobalStyle.sectionTitle), ], ), Wrap( @@ -476,7 +484,9 @@ class _VisitPhotoTypologyDetailPageState child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text('Competitor', + Text( + AppLocalizations.of(context)! + .translate('i18n_label_competition'), style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold)), SizedBox( height: 16, @@ -509,7 +519,8 @@ class _VisitPhotoTypologyDetailPageState children: [ Icon(Icons.thumb_down, color: SOFT_BLUE), SizedBox(width: 12), - Text('Choose Competitor', + Text(AppLocalizations.of(context)! + .translate('i18n_label_choose_competitor'), style: TextStyle( color: CHARCOAL, fontWeight: FontWeight.bold)), @@ -557,7 +568,8 @@ class _VisitPhotoTypologyDetailPageState ), Container( margin: EdgeInsets.fromLTRB(16, 8, 16, 8), - child: Text('Choose Competitor', style: GlobalStyle.chooseCourier), + child: Text(AppLocalizations.of(context)! + .translate('i18n_label_choose_competitor'), style: GlobalStyle.chooseCourier), ), Flexible( child: ListView.builder( diff --git a/lib/ui/visit/visit_photo_typology_list.dart b/lib/ui/visit/visit_photo_typology_list.dart index a9f9c53..c767937 100644 --- a/lib/ui/visit/visit_photo_typology_list.dart +++ b/lib/ui/visit/visit_photo_typology_list.dart @@ -24,6 +24,7 @@ import 'package:mobdr/ui/reusable/reusable_widget.dart'; import 'package:mobdr/events.dart'; import 'package:mobdr/service/plausible.dart'; import 'package:mobdr/service/logger_util.dart'; +import 'package:mobdr/cubit/language/app_localizations.dart'; extension FileNameExtension on File { String getFileName() { @@ -182,7 +183,8 @@ class _VisitPhotoTypologyListPageState borderRadius: BorderRadius.all(Radius.circular( 10) // <--- border radius here )), - child: Text('Prendre des photos', + child: Text( + AppLocalizations.of(context)!.translate('i18n_label_take_photos'), style: TextStyle( color: SOFT_BLUE, fontWeight: FontWeight.bold)), ), @@ -269,7 +271,8 @@ class _VisitPhotoTypologyListPageState ), Container(height: 8), Text( - "Private : ${photoData.photo_privee == 1 ? 'Yes' : 'No'}", + AppLocalizations.of(context)!.translate('i18n_label_private_visibility') + " : ${photoData.photo_privee == 1 ? + AppLocalizations.of(context)!.translate('i18n_label_yes') : AppLocalizations.of(context)!.translate('i18n_label_no')}", style: TextStyle(fontSize: 13, color: _color2), maxLines: 3, overflow: TextOverflow.ellipsis, @@ -277,7 +280,7 @@ class _VisitPhotoTypologyListPageState Container( margin: EdgeInsets.only(top: 5), child: Text( - '${photoData.tags.isNotEmpty ? (photoData.tags.length > 53 ? '${photoData.tags.substring(0, 50)}...' : photoData.tags) : "notag"}', + '${photoData.tags.isNotEmpty ? (photoData.tags.length > 53 ? '${photoData.tags.substring(0, 50)}...' : photoData.tags) : AppLocalizations.of(context)!.translate('i18n_label_notag')}', style: TextStyle( fontSize: 13, fontWeight: FontWeight.bold), ), @@ -328,7 +331,7 @@ class _VisitPhotoTypologyListPageState }); Fluttertoast.showToast( - msg: 'The image has been rotated'); + msg: AppLocalizations.of(context)!.translate('i18n_label_image_rotated')); }, child: Container( padding: EdgeInsets.fromLTRB(5, 0, 5, 0), @@ -364,7 +367,7 @@ class _VisitPhotoTypologyListPageState }); Fluttertoast.showToast( - msg: 'The image has been rotated'); + msg: AppLocalizations.of(context)!.translate('i18n_label_image_rotated')); }, child: Container( padding: EdgeInsets.fromLTRB(5, 0, 5, 0), @@ -472,7 +475,9 @@ class _VisitPhotoTypologyListPageState onPressed: () { Navigator.pop(context); }, - child: Text('No', style: TextStyle(color: SOFT_BLUE))); + child: Text( + AppLocalizations.of(context)! + .translate('i18n_label_no'), style: TextStyle(color: SOFT_BLUE))); Widget continueButton = TextButton( onPressed: () { int removeIndex = index; @@ -508,10 +513,13 @@ class _VisitPhotoTypologyListPageState LoggerUtil.dblog('LOG', 'MOBDR', 'Suppression photo', 0); Fluttertoast.showToast( - msg: 'Photo has been deleted from your visit', + msg: AppLocalizations.of(context)! + .translate('i18n_label_deleted_photo'), toastLength: Toast.LENGTH_SHORT); }, - child: Text('Yes', style: TextStyle(color: SOFT_BLUE))); + child: Text( + AppLocalizations.of(context)! + .translate('i18n_label_yes'), style: TextStyle(color: SOFT_BLUE))); // set up the AlertDialog AlertDialog alert = AlertDialog( @@ -519,10 +527,11 @@ class _VisitPhotoTypologyListPageState borderRadius: BorderRadius.circular(10), ), title: Text( - 'Delete Photo', + AppLocalizations.of(context)!.translate('i18n_label_delete_photo'), style: TextStyle(fontSize: 18), ), - content: Text('Are you sure to delete this photo from your visit ?', + content: Text( + AppLocalizations.of(context)!.translate('i18n_label_confirm_delete_photo'), style: TextStyle(fontSize: 13, color: _color1)), actions: [ cancelButton, diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index 0324376..becef64 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -203,7 +203,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1430; ORGANIZATIONNAME = ""; TargetAttributes = { 33CC10EC2044A3C60003C045 = { diff --git a/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index c169b97..c18d491 100644 --- a/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@