From 499ed4576682b14c71d5ee30437433523528a8f8 Mon Sep 17 00:00:00 2001 From: Aman Raj Date: Wed, 31 May 2023 20:50:06 +0530 Subject: [PATCH 1/2] translate the offline data page --- packages/smooth_app/lib/l10n/app_en.arb | 71 +++++++++++++++++++ .../lib/pages/offline_data_page.dart | 42 ++++++----- 2 files changed, 94 insertions(+), 19 deletions(-) diff --git a/packages/smooth_app/lib/l10n/app_en.arb b/packages/smooth_app/lib/l10n/app_en.arb index fe94216b522..92ecfa40a72 100644 --- a/packages/smooth_app/lib/l10n/app_en.arb +++ b/packages/smooth_app/lib/l10n/app_en.arb @@ -2073,5 +2073,76 @@ "page_not_found_button": "Go back to the homepage", "@page_not_found_button": { "description": "Button to go back to the homepage" + }, + "download_data": "Download Data", + "@download_data": { + "description": "App bar title for the download data page" + }, + "download_top_products": "Download the top 1000 products in your country for instant scanning", + "@download_top_products": { + "description": "Download the top 1000 products in your country for instant scanning" + }, + "download_in_progress": "Downloading data\nThis may take a while", + "@download_in_progress": { + "description": "Download in progress" + }, + "downloaded_products": "{num} products added", + "@downloaded_products": { + "description": "text to show when products added", + "placeholders": { + "num": { + "type": "int" + } + } + }, + "update_offline_data": "Update Offline Product Data", + "@update_offline_data": { + "description": "List tile title for the update offline data page" + }, + "update_local_database_sub": "Update the local product database with the latest data from server", + "@update_local_database_sub": { + "description": "Update the local product database with the latest data from server" + }, + "clear_local_database": "Clear Offline Product Data", + "@clear_local_database": { + "description": "List tile title for the clear local database page" + }, + "clear_local_database_sub": "Clear all local product data from your app to free up space", + "@clear_local_database_sub": { + "description": "Clear all local product data from your app to free up space" + }, + "deleted_products": "{num} products deleted", + "@deleted_products": { + "description": "text to show when products are deleted from local databse", + "placeholders": { + "num": { + "type": "int" + } + } + }, + "loading": "Loading...", + "@loading": { + "description": "Loading..." + }, + "know_more": "Know More", + "@know_more": { + "description": "Know More" + }, + "offline_data_desc": "Click to know more about offline data", + "@offline_data_desc": { + "description": "Click to know more about offline data" + }, + "offline_product_data_title": "Offline Product Data", + "@offline_product_data_title": { + "description": "Offline Product Data" + }, + "available_for_download": "{num} products available for immediate scaning", + "@available_for_download": { + "description": "text to show details of products available for download", + "placeholders": { + "num": { + "type": "int" + } + } } } \ No newline at end of file diff --git a/packages/smooth_app/lib/pages/offline_data_page.dart b/packages/smooth_app/lib/pages/offline_data_page.dart index 3fde5ea8e8c..cf278cfb9b5 100644 --- a/packages/smooth_app/lib/pages/offline_data_page.dart +++ b/packages/smooth_app/lib/pages/offline_data_page.dart @@ -123,15 +123,14 @@ class _OfflineDataPageState extends State { daoProduct: daoProduct, ), _OfflinePageListTile( - title: 'Download Data', - subtitle: - 'Download the top 1000 products in your country for instant scanning', + title: appLocalizations.download_data, + subtitle: appLocalizations.download_top_products, onTap: () async { final LocalDatabase localDatabase = context.read(); final DaoProduct daoProduct = DaoProduct(localDatabase); final int newlyAddedProducts = await LoadingDialog.run( - title: 'Downloading data\nThis may take a while', + title: appLocalizations.download_in_progress, context: context, future: PreloadDataHelper(daoProduct).downloadTopProducts(), @@ -140,7 +139,9 @@ class _OfflineDataPageState extends State { // ignore: use_build_context_synchronously ScaffoldMessenger.of(context).showSnackBar( SnackBar( - content: Text('$newlyAddedProducts products added'), + content: Text( + appLocalizations.downloaded_products(newlyAddedProducts), + ), ), ); localDatabase.notifyListeners(); @@ -148,13 +149,12 @@ class _OfflineDataPageState extends State { trailing: const Icon(Icons.download), ), _OfflinePageListTile( - title: 'Update Offline Product Data', - subtitle: - 'Update the local product database with the latest data from server', + title: appLocalizations.update_offline_data, + subtitle: appLocalizations.update_local_database_sub, trailing: const Icon(Icons.refresh), onTap: () async { final int newlyAddedProducts = await LoadingDialog.run( - title: 'Downloading data\nThis may take a while', + title: appLocalizations.download_in_progress, context: context, future: updateLocalDatabaseFromServer(context), ) ?? @@ -164,7 +164,8 @@ class _OfflineDataPageState extends State { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - '$newlyAddedProducts products updated', + appLocalizations + .downloaded_products(newlyAddedProducts), ), duration: SnackBarDuration.brief, ), @@ -173,16 +174,17 @@ class _OfflineDataPageState extends State { }, ), _OfflinePageListTile( - title: 'Clear Offline Product Data', - subtitle: - 'Clear all local product data from your app to free up space', + title: appLocalizations.clear_local_database, + subtitle: appLocalizations.clear_local_database_sub, trailing: const Icon(Icons.delete), onTap: () async { final int totalProductsDeleted = await daoProduct.deleteAll(); if (mounted) { ScaffoldMessenger.of(context).showSnackBar( SnackBar( - content: Text('$totalProductsDeleted products deleted'), + content: Text( + appLocalizations.deleted_products(totalProductsDeleted), + ), duration: SnackBarDuration.brief, ), ); @@ -191,8 +193,8 @@ class _OfflineDataPageState extends State { }, ), _OfflinePageListTile( - title: 'Know More', - subtitle: 'Click to know more about offline data', + title: appLocalizations.know_more, + subtitle: appLocalizations.offline_data_desc, trailing: const Icon(Icons.info), // ignore: avoid_returning_null_for_void onTap: () => null, @@ -215,18 +217,20 @@ class _StatsWidget extends StatelessWidget { @override Widget build(BuildContext context) { + final AppLocalizations applocalizations = AppLocalizations.of(context); return Padding( padding: const EdgeInsets.symmetric(vertical: SMALL_SPACE), child: ListTile( - title: const Text('Offline Product Data'), + title: Text(applocalizations.offline_product_data_title), subtitle: FutureBuilder( future: daoProduct.getTotalNoOfProducts(), builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.hasData) { return Text( - '${snapshot.data} products available for immediate scaning'); + applocalizations.available_for_download(snapshot.data!), + ); } else { - return const Text('Loading...'); + return Text(applocalizations.loading); } }, ), From 83c335a0d50fc69ed0e36bc27de63ac36a8f7c4b Mon Sep 17 00:00:00 2001 From: Pierre Slamich Date: Thu, 1 Jun 2023 10:13:49 +0200 Subject: [PATCH 2/2] Apply suggestions from code review --- packages/smooth_app/lib/l10n/app_en.arb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/smooth_app/lib/l10n/app_en.arb b/packages/smooth_app/lib/l10n/app_en.arb index 92ecfa40a72..288c97fb7d3 100644 --- a/packages/smooth_app/lib/l10n/app_en.arb +++ b/packages/smooth_app/lib/l10n/app_en.arb @@ -2074,7 +2074,7 @@ "@page_not_found_button": { "description": "Button to go back to the homepage" }, - "download_data": "Download Data", + "download_data": "Download data", "@download_data": { "description": "App bar title for the download data page" }, @@ -2095,15 +2095,15 @@ } } }, - "update_offline_data": "Update Offline Product Data", + "update_offline_data": "Update offline product data", "@update_offline_data": { "description": "List tile title for the update offline data page" }, - "update_local_database_sub": "Update the local product database with the latest data from server", + "update_local_database_sub": "Update the local product database with the latest data from Open Food Facts", "@update_local_database_sub": { "description": "Update the local product database with the latest data from server" }, - "clear_local_database": "Clear Offline Product Data", + "clear_local_database": "Clear offline product data", "@clear_local_database": { "description": "List tile title for the clear local database page" }, @@ -2120,9 +2120,9 @@ } } }, - "loading": "Loading...", + "loading": "Loading…", "@loading": { - "description": "Loading..." + "description": "Loading…" }, "know_more": "Know More", "@know_more": { @@ -2132,7 +2132,7 @@ "@offline_data_desc": { "description": "Click to know more about offline data" }, - "offline_product_data_title": "Offline Product Data", + "offline_product_data_title": "Offline product data", "@offline_product_data_title": { "description": "Offline Product Data" },