Skip to content

Commit

Permalink
launch_url: Add i18n for launchUrl error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
VatsalBhesaniya committed May 23, 2024
1 parent ed81d05 commit 5a0a178
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 11 additions & 0 deletions assets/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,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."
},
"errorUnableToOpenLinkMessage": "Link could not be opened: {url}",
"@errorUnableToOpenLinkMessage": {
"description": "Error message when a link fails to open.",
"placeholders": {
"url": {"type": "String", "example": "http://example.com/"}
}
},
"loginHidePassword": "Hide password",
"@loginHidePassword": {
"description": "Icon label for button to hide password in input form."
Expand Down
6 changes: 4 additions & 2 deletions lib/widgets/launch_url.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -10,11 +11,12 @@ import 'store.dart';

/// Handles showing an error dialog with a customizable message.
Future<void> _showError(BuildContext context, String? message, String urlString) {
final zulipLocalizations = ZulipLocalizations.of(context);
return showErrorDialog(
context: context,
title: 'Unable to open link',
title: zulipLocalizations.errorUnableToOpenLinkTitle,
message: [
'Link could not be opened: $urlString',
zulipLocalizations.errorUnableToOpenLinkMessage(urlString),
if (message != null) message,
].join("\n\n"));
}
Expand Down

0 comments on commit 5a0a178

Please sign in to comment.