Skip to content

Comments

Fix: Replace hardcoded strings with AppLocalizations keys#321

Open
g-k-s-03 wants to merge 1 commit intofossasia:mainfrom
g-k-s-03:fix/localization-context-usage
Open

Fix: Replace hardcoded strings with AppLocalizations keys#321
g-k-s-03 wants to merge 1 commit intofossasia:mainfrom
g-k-s-03:fix/localization-context-usage

Conversation

@g-k-s-03
Copy link

@g-k-s-03 g-k-s-03 commented Jan 7, 2026

closes #288
Description:
This pull request replaces all hardcoded string literals in ImageEditor and BottomActionMenu with localized keys from AppLocalizations.

Changes included:

Replaced hardcoded labels like "Import", "Text", "OK" with appLocalizations.import, appLocalizations.text, and appLocalizations.ok.
Updated dialog buttons and action menu labels to use localization.
Ensures that the app supports multiple languages consistently.

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.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Sorry @g-k-s-03, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@Dhruv1797 Dhruv1797 self-requested a review January 20, 2026 07:22
@g-k-s-03
Copy link
Author

Hi @mariobehling ,
This PR has been approved by a reviewer.
There is one workflow awaiting approval.
Could you please review and approve the workflow so it can be merged?
Thanks!

@mariobehling mariobehling requested a review from Copilot February 9, 2026 17:41
@mariobehling
Copy link
Member

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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 introduced AppLocalizations.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.

Comment on lines 321 to 324
@override
Widget build(BuildContext context) {
final appLocalizations = AppLocalizations.of(context)!;
var imgLoader = context.watch<ImageLoader>();
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@@ -22,7 +22,6 @@ import 'package:magicepaperapp/l10n/app_localizations.dart';
import '../util/app_logger.dart';
import 'package:magicepaperapp/provider/getitlocator.dart';
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

getitlocator.dart is now unused in this file after removing getIt.get<AppLocalizations>(). Please remove the unused import to keep flutter analyze clean.

Suggested change
import 'package:magicepaperapp/provider/getitlocator.dart';

Copilot uses AI. Check for mistakes.
context: context,
icon: Icons.add_photo_alternate_outlined,
label: "Import",
label: appLocalizations.import,
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

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).

Suggested change
label: appLocalizations.import,
label: appLocalizations.importImageButtonLabel,

Copilot uses AI. Check for mistakes.
context: context,
icon: Icons.text_fields,
label: "Text",
label: appLocalizations.text,
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

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).

Suggested change
label: appLocalizations.text,
label: 'Text',

Copilot uses AI. Check for mistakes.
Comment on lines +581 to 582
final appLocalizations = AppLocalizations.of(context)!;
return SafeArea(
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
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.

Incorrect usage of AppLocalizations causing localization issues

3 participants