Skip to content

Internationalize hardcoded SnackBar messages#424

Merged
grunch merged 2 commits intomainfrom
translate-snackbar-messages
Feb 5, 2026
Merged

Internationalize hardcoded SnackBar messages#424
grunch merged 2 commits intomainfrom
translate-snackbar-messages

Conversation

@Catrya
Copy link
Member

@Catrya Catrya commented Feb 3, 2026

fix #414

Summary by CodeRabbit

  • New Features

    • Expanded localization coverage for error messages, success notifications, and user feedback across chat, file uploads, order management, and dispute features.
    • Added Spanish and Italian translations alongside English for improved international user experience.
  • Style

    • Refined switch component styling in notification settings for enhanced visual consistency.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 3, 2026

Walkthrough

This pull request internationalizes hardcoded English SnackBar messages and UI text across the codebase by replacing them with localized strings from generated localization resources. New translation keys are added to English, Spanish, and Italian localization files, while widget files are updated to use S.of(context)! calls instead of literal strings.

Changes

Cohort / File(s) Summary
Widget Message Localization
lib/features/chat/widgets/encrypted_file_message.dart, lib/features/chat/widgets/message_input.dart, lib/features/disputes/widgets/dispute_input_section.dart, lib/features/disputes/widgets/dispute_message_bubble.dart, lib/features/order/screens/add_lightning_invoice_screen.dart, lib/shared/widgets/clickable_text_widget.dart, lib/shared/widgets/exchange_rate_widget.dart
Replace hardcoded error and status messages with localized strings using S.of(context)!.<key>() calls; add localization imports where needed.
Localization Keys
lib/l10n/intl_en.arb, lib/l10n/intl_es.arb, lib/l10n/intl_it.arb
Add new translation keys (failedToCancelOrder, refreshingExchangeRate, textCopiedToClipboard, messageSent, couldNotOpenFileWithMessage, errorOpeningFileWithMessage, errorUploadingFile) with placeholders and translations across English, Spanish, and Italian.
UI Styling
lib/features/settings/notification_settings_screen.dart
Change activeColor to activeThumbColor on two Switch widgets for thumb styling consistency.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • grunch
  • AndreaDiazCorreia

Poem

🐰 Strings once hard-coded in English so plain,
Now flutter with translations through Spain and Milano's domain,
Each snackbar and message gets localized care,
The world speaks in languages, everywhere! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning One out-of-scope change detected: lib/features/settings/notification_settings_screen.dart swaps activeColor for activeThumbColor on Switch widgets, which is unrelated to SnackBar message localization. Remove the activeColor→activeThumbColor changes from notification_settings_screen.dart as they are unrelated to the SnackBar localization objective.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'Internationalize hardcoded SnackBar messages' clearly and concisely describes the main change: replacing hardcoded English SnackBar strings with localized strings across multiple files.
Linked Issues check ✅ Passed The PR successfully implements all requirements from issue #414: replaced hardcoded strings with localized variants in all 7 specified files, added new translation keys to all 3 ARB files (English, Spanish, Italian), and used S.of(context)!. pattern throughout.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch translate-snackbar-messages

Important

Action Needed: IP Allowlist Update

If your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:

  • 136.113.208.247/32 (new)
  • 34.170.211.100/32
  • 35.222.179.152/32

Failure to add the new IP will result in interrupted reviews.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
lib/features/chat/widgets/message_input.dart (1)

128-135: ⚠️ Potential issue | 🟠 Major

Don’t surface raw exception details in the Snackbar.

Issue #414 asks to log the exception and show a user-friendly message; the current message includes e.toString().

Proposed fix
-    } catch (e) {
-      // Show error to user
-      if (mounted) {
-        SnackBarHelper.showTopSnackBar(
-          context,
-          S.of(context)!.errorUploadingFile(e.toString()),
-          backgroundColor: Colors.red,
-        );
-      }
-    } finally {
+    } catch (e, st) {
+      debugPrint('File upload failed: $e\n$st');
+      if (mounted) {
+        SnackBarHelper.showTopSnackBar(
+          context,
+          S.of(context)!.errorUploadingFileGeneric,
+          backgroundColor: Colors.red,
+        );
+      }
+    } finally {

You’ll need to add a non-parameterized key (e.g., errorUploadingFileGeneric) to all three ARB files.

🤖 Fix all issues with AI agents
In `@lib/l10n/intl_en.arb`:
- Around line 699-706: Add a metadata block for the "refreshingExchangeRate" key
in all three ARB files (intl_en.arb, intl_es.arb, intl_it.arb) by adding an
"@refreshingExchangeRate" object immediately after the string entry that
includes a "description" (e.g., "Status shown while the exchange rate is being
refreshed") and a "type": "text" field; ensure the metadata object matches the
ARB format used elsewhere (no placeholders object since there are no template
variables).

In `@lib/l10n/intl_es.arb`:
- Around line 612-619: Add the missing ARB metadata entry for the key
"refreshingExchangeRate": create an "@refreshingExchangeRate" object next to
"refreshingExchangeRate" with a "description" and empty "placeholders" (or
appropriate placeholders if any) so ARB metadata remains consistent; apply the
same addition to all three locale files (intl_en.arb, intl_es.arb, intl_it.arb)
ensuring the key name "refreshingExchangeRate" and its metadata
"@refreshingExchangeRate" match exactly.

In `@lib/l10n/intl_it.arb`:
- Around line 642-649: Add an ARB metadata entry for the new localization key
"refreshingExchangeRate" (i.e. add an "@refreshingExchangeRate" JSON object) in
the Italian file and mirror the same metadata in the English and Spanish ARB
files; the metadata should follow the existing pattern (include a "description"
and a "placeholders" object—empty if there are no placeholders) so flutter_intl
recognizes the new key consistently across en, es, it.

In `@lib/shared/widgets/clickable_text_widget.dart`:
- Around line 39-45: The snackbar currently only shows widget.clickableText,
dropping the leftText label; update _handleTap so SnackBarHelper.showTopSnackBar
passes the full label (e.g., concatenate widget.leftText + widget.clickableText
or pass both into the localization helper) when calling
S.of(context)!.textCopiedToClipboard, then still await
Clipboard.setData(ClipboardData(text: widget.clickableText)); ensure you
reference _handleTap, SnackBarHelper.showTopSnackBar,
S.of(context)!.textCopiedToClipboard, widget.leftText and widget.clickableText
when making the change.
🧹 Nitpick comments (2)
lib/features/order/screens/add_lightning_invoice_screen.dart (1)

83-86: Wrap the SnackBar call in a post-frame callback.

This is a screen file, so the SnackBar side effect should be queued post-frame.

Proposed fix
-                        if (context.mounted) {
-                          SnackBarHelper.showTopSnackBar(
-                            context,
-                            S.of(context)!.failedToCancelOrder(e.toString()),
-                          );
-                        }
+                        if (context.mounted) {
+                          WidgetsBinding.instance.addPostFrameCallback((_) {
+                            SnackBarHelper.showTopSnackBar(
+                              context,
+                              S.of(context)!.failedToCancelOrder(e.toString()),
+                            );
+                          });
+                        }

As per coding guidelines: Use post-frame callbacks for side effects like SnackBars and dialogs.

lib/features/disputes/widgets/dispute_input_section.dart (1)

126-144: Avoid showing raw exception text in the SnackBar.
Line 141 surfaces error.toString() to users. Consider logging the raw error and showing a generic localized failure message instead to avoid exposing technical details.

Copy link
Member

@grunch grunch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@grunch grunch merged commit 4af6c5d into main Feb 5, 2026
2 checks passed
@Catrya Catrya deleted the translate-snackbar-messages branch February 13, 2026 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Internationalize hardcoded SnackBar messages

2 participants