Skip to content

Conversation

@mrashutoshnigam
Copy link
Contributor

Code Quality: Centralize and Refactor Localization Strings in Files App

This pull request aims to improve code quality and maintainability in the Files App by centralizing localization strings and replacing string literals with string constants. The changes enhance consistency, reduce the risk of typos, and streamline future updates and localization efforts.

Closes #16718

Changes Made

  • Created a centralized Strings class to manage all localization strings.
  • Refactored localization strings in the following actions:
    • DeleteItemAction
    • DeleteItemPermanentlyAction
    • EmptyRecycleBinAction
    • FlattenFolderAction
    • OpenFileLocationAction
    • OpenItemAction
    • OpenItemWithApplicationPickerAction
    • OpenParentFolderAction
  • Updated labels and descriptions for improved user experience.
  • Replaced string literals with corresponding string constants throughout the Files App codebase.
  • Updated confirmation dialog content in EmptyRecycleBinAction and FlattenFolderAction.

Benefits

  • Improved maintainability: All strings are now managed in one place.
  • Enhanced consistency across the application.
  • Reduced likelihood of typos and errors.
  • Improved code readability.
  • Streamlined future updates and localization efforts.

Testing Steps

  1. Open Files App.
  2. Check Right Click menu, focusing on the refactored actions (Delete, Empty Recycle Bin, Flatten Folder, etc.).
  3. Perform actions that trigger string-dependent functionality, especially those with confirmation dialogs.
  4. Update language via settings and repeat steps 2 and 3.
  5. Verify that no visual or functional regressions occurred due to the changes.
  6. Check for any compile-time errors or warnings related to string usage.

Additional Notes

  • This change does not alter any functionality but improves code maintainability.
  • Code reviewers should pay special attention to ensure no string literals were missed during this refactoring.
  • Special focus should be given to the confirmation dialogs in EmptyRecycleBinAction and FlattenFolderAction to ensure they display correctly.

Replaced hardcoded localization string keys with references to a centralized `Strings` class in the `Files.App.Actions` namespace. This change improves maintainability and consistency in localization across the application.
Refactor localization in `Files.App.Actions` namespace by replacing hardcoded string values for labels and descriptions with references to a centralized `Strings` class. This change enhances maintainability and consistency across the application. Updated classes include `DeleteItemAction`, `DeleteItemPermanentlyAction`, `EmptyRecycleBinAction`, `FlattenFolderAction`, `OpenFileLocationAction`, `OpenItemAction`, `OpenItemWithApplicationPickerAction`, and `OpenParentFolderAction`. Additionally, confirmation dialog content in `EmptyRecycleBinAction` and `FlattenFolderAction` has been updated to use the new localization strings.
Copy link
Member

@yaira2 yaira2 left a comment

Choose a reason for hiding this comment

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

LGTM

@yaira2 yaira2 added the ready to merge Pull requests that are approved and ready to merge label Feb 28, 2025
@yaira2 yaira2 merged commit 4dca184 into files-community:main Feb 28, 2025
6 checks passed
@mrashutoshnigam mrashutoshnigam deleted the codeQuality/replaceStringsLiteralsWithContants_16718_03 branch February 28, 2025 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready to merge Pull requests that are approved and ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Code Quality: Replace string.GetLocalizedResource() with Strings.object.GetLocalizedResource()

2 participants