Internationalize hardcoded SnackBar messages#424
Conversation
WalkthroughThis 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 Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Important Action Needed: IP Allowlist UpdateIf your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:
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. Comment |
There was a problem hiding this comment.
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 | 🟠 MajorDon’t surface raw exception details in the Snackbar.
Issue
#414asks to log the exception and show a user-friendly message; the current message includese.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 surfaceserror.toString()to users. Consider logging the raw error and showing a generic localized failure message instead to avoid exposing technical details.
fix #414
Summary by CodeRabbit
New Features
Style