Fix: Replace hardcoded strings with AppLocalizations keys#321
Fix: Replace hardcoded strings with AppLocalizations keys#321g-k-s-03 wants to merge 1 commit intofossasia:mainfrom
Conversation
|
Hi @mariobehling , |
|
Small process note. We have automatic Copilot PR reviews enabled on this repository. These reviews are only triggered if the contributor has GitHub Copilot enabled and an active license on their own account. Please enable Copilot in your GitHub settings if you have access. In many regions, free licenses are available through educational institutions or developer programs. Enabling Copilot helps us speed up the auto review process and reduces manual review overhead for the core team. The team will review your PR. Thank you for your contribution and cooperation. |
There was a problem hiding this comment.
Pull request overview
This PR updates the Image Editor UI to use AppLocalizations instead of hardcoded strings, aligning the ImageEditor and BottomActionMenu labels/buttons with Flutter’s localization system (and moving away from getIt-retrieved localizations in this screen).
Changes:
- Removed the file-level
getIt.get<AppLocalizations>()usage and introducedAppLocalizations.of(context)usage. - Replaced some hardcoded UI strings (e.g., “OK”, “Import”, “Text”) with localization lookups.
- Updated BottomActionMenu button labels to use localized strings.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @override | ||
| Widget build(BuildContext context) { | ||
| final appLocalizations = AppLocalizations.of(context)!; | ||
| var imgLoader = context.watch<ImageLoader>(); |
There was a problem hiding this comment.
After removing the file-level appLocalizations variable, several methods in this file still reference appLocalizations (e.g., _exportXbmFiles, _showRefreshModeInfoDialog). The new final appLocalizations = AppLocalizations.of(context)!; inside build() is not in scope for those methods, which will cause a compile error. Consider adding a State getter (e.g., AppLocalizations get appLocalizations => AppLocalizations.of(context)!;) or retrieving AppLocalizations.of(context)! locally inside each method that needs it.
| @@ -22,7 +22,6 @@ import 'package:magicepaperapp/l10n/app_localizations.dart'; | |||
| import '../util/app_logger.dart'; | |||
| import 'package:magicepaperapp/provider/getitlocator.dart'; | |||
There was a problem hiding this comment.
getitlocator.dart is now unused in this file after removing getIt.get<AppLocalizations>(). Please remove the unused import to keep flutter analyze clean.
| import 'package:magicepaperapp/provider/getitlocator.dart'; |
| context: context, | ||
| icon: Icons.add_photo_alternate_outlined, | ||
| label: "Import", | ||
| label: appLocalizations.import, |
There was a problem hiding this comment.
appLocalizations.import does not appear to exist in the generated AppLocalizations API (and import is also a Dart keyword). This will not compile; use an existing key such as importImageButtonLabel (or add a new ARB key and regenerate localizations).
| label: appLocalizations.import, | |
| label: appLocalizations.importImageButtonLabel, |
| context: context, | ||
| icon: Icons.text_fields, | ||
| label: "Text", | ||
| label: appLocalizations.text, |
There was a problem hiding this comment.
appLocalizations.text does not exist in the generated AppLocalizations API, so this will not compile. Please switch to the correct existing localization key for this action label (or add it to the ARB files and regenerate).
| label: appLocalizations.text, | |
| label: 'Text', |
| final appLocalizations = AppLocalizations.of(context)!; | ||
| return SafeArea( |
There was a problem hiding this comment.
Minor formatting: this line has an extra leading space compared to surrounding indentation; run dart format (or fix indentation) to match the file’s formatting.
closes #288
Description:
This pull request replaces all hardcoded string literals in ImageEditor and BottomActionMenu with localized keys from AppLocalizations.
Changes included:
Checklist:
All user-facing strings now use localization.
Verified that dialogs, buttons, and menus display correctly.
No hardcoded strings remain (confirmed using search).
Testing:
Opened Image Editor and Bottom Action Menu to verify all labels.
Tested dialogs and action buttons to confirm proper localized text.