From b715ce36364b5331cf24285a3837382e7b9a78de Mon Sep 17 00:00:00 2001 From: Vatsal Date: Fri, 29 Mar 2024 12:38:02 +0530 Subject: [PATCH] launch_url: Add i18n for launchUrl error messages - Utilize i18n for consistent error messaging. --- assets/l10n/app_en.arb | 11 +++++++++++ lib/widgets/launch_url.dart | 5 +++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/assets/l10n/app_en.arb b/assets/l10n/app_en.arb index fb7040ed8f3..c33acae5c86 100644 --- a/assets/l10n/app_en.arb +++ b/assets/l10n/app_en.arb @@ -289,6 +289,17 @@ "@loginServerUrlInputLabel": { "description": "Input label in login page for Zulip server URL entry." }, + "errorUnableToOpenLinkTitle": "Unable to open link", + "@errorUnableToOpenLinkTitle": { + "description": "Error title when a link fails to open." + }, + "errorLinkCouldNotBeOpened": "Link could not be opened: {url}", + "@errorLinkCouldNotBeOpened": { + "description": "Error message when a specific link could not be opened.", + "placeholders": { + "url": {"type": "String", "example": "http://example.com/"} + } + }, "loginHidePassword": "Hide password", "@loginHidePassword": { "description": "Icon label for button to hide password in input form." diff --git a/lib/widgets/launch_url.dart b/lib/widgets/launch_url.dart index dfc0fae07ee..8d5f15694cd 100644 --- a/lib/widgets/launch_url.dart +++ b/lib/widgets/launch_url.dart @@ -1,6 +1,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_gen/gen_l10n/zulip_localizations.dart'; import '../model/binding.dart'; import '../model/internal_link.dart'; @@ -12,9 +13,9 @@ import 'store.dart'; Future _showError(BuildContext context, String? message, String urlString) { return showErrorDialog( context: context, - title: 'Unable to open link', + title: ZulipLocalizations.of(context).errorUnableToOpenLinkTitle, message: [ - 'Link could not be opened: $urlString', + ZulipLocalizations.of(context).errorLinkCouldNotBeOpened(urlString), if (message != null) message, ].join("\n\n")); }