From 72ef83e1a28fc74d78f3ceb6b8db5be23d0530e2 Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Fri, 24 Apr 2026 13:15:24 +0200 Subject: [PATCH] Translate the sync status in the main icon --- lib/l10n/app_en.arb | 26 +++++++++++++++++++++++++- lib/widgets/core/app_bar.dart | 22 ++++++++++++---------- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index c41edca55..f49fbcdb9 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -1214,5 +1214,29 @@ } }, "searchLanguageAll": "All languages", - "@searchLanguageAll": {} + "@searchLanguageAll": {}, + "syncStatusConnected": "Connected", + "@syncStatusConnected": { + "description": "Tooltip on the sync icon when the app is online and idle (no upload or download in progress)" + }, + "syncStatusConnecting": "Connecting", + "@syncStatusConnecting": { + "description": "Tooltip on the sync icon while the app is establishing a connection to the sync service" + }, + "syncStatusDisconnected": "Not connected", + "@syncStatusDisconnected": { + "description": "Tooltip on the sync icon when the app has no active connection to the sync service" + }, + "syncStatusUploading": "Uploading", + "@syncStatusUploading": { + "description": "Tooltip on the sync icon while local changes are being uploaded to the server" + }, + "syncStatusDownloading": "Downloading", + "@syncStatusDownloading": { + "description": "Tooltip on the sync icon while remote changes are being downloaded from the server" + }, + "syncStatusSyncing": "Synchronizing", + "@syncStatusSyncing": { + "description": "Tooltip on the sync icon when the app is uploading and downloading at the same time" + } } diff --git a/lib/widgets/core/app_bar.dart b/lib/widgets/core/app_bar.dart index 67e64a9ea..f9b3dfc54 100644 --- a/lib/widgets/core/app_bar.dart +++ b/lib/widgets/core/app_bar.dart @@ -34,13 +34,13 @@ import 'package:wger/widgets/user/forms.dart'; Widget _makeIcon(String text, IconData icon) { return Tooltip( message: text, - child: SizedBox(width: 40, height: null, child: Icon(icon, size: 24)), + child: SizedBox(width: 40, child: Icon(icon, size: 24)), ); } -Widget _getStatusIcon(ps.SyncStatus status) { +Widget _getStatusIcon(ps.SyncStatus status, AppLocalizations i18n) { if (status.anyError != null) { - // The error message is verbose, could be replaced with something + // TODO: The error message might be verbose, could be replaced with something // more user-friendly if (!status.connected) { return _makeIcon(status.anyError!.toString(), Icons.cloud_off); @@ -48,19 +48,21 @@ Widget _getStatusIcon(ps.SyncStatus status) { return _makeIcon(status.anyError!.toString(), Icons.sync_problem); } } else if (status.connecting) { - return _makeIcon('Connecting', Icons.cloud_sync_outlined); + // Distinct from the active-sync icon below: "queue" reads as + // "trying to establish a connection", not "transferring data". + return _makeIcon(i18n.syncStatusConnecting, Icons.cloud_queue); } else if (!status.connected) { - return _makeIcon('Not connected', Icons.cloud_off); + return _makeIcon(i18n.syncStatusDisconnected, Icons.cloud_off); } else if (status.uploading && status.downloading) { // The status changes often between downloading, uploading and both, // so we use the same icon for all three - return _makeIcon('Uploading and downloading', Icons.cloud_sync_outlined); + return _makeIcon(i18n.syncStatusSyncing, Icons.cloud_sync_outlined); } else if (status.uploading) { - return _makeIcon('Uploading', Icons.cloud_upload_outlined); + return _makeIcon(i18n.syncStatusUploading, Icons.cloud_upload_outlined); } else if (status.downloading) { - return _makeIcon('Downloading', Icons.cloud_download_outlined); + return _makeIcon(i18n.syncStatusDownloading, Icons.cloud_download_outlined); } else { - return _makeIcon('Connected', Icons.cloud_done_outlined); + return _makeIcon(i18n.syncStatusConnected, Icons.cloud_done_outlined); } } @@ -72,7 +74,7 @@ class MainAppBar extends ConsumerWidget implements PreferredSizeWidget { @override Widget build(BuildContext context, WidgetRef ref) { final syncState = ref.watch(syncStatus); - final statusIcon = _getStatusIcon(syncState); + final statusIcon = _getStatusIcon(syncState, AppLocalizations.of(context)); return AppBar( title: Text(_title),