Skip to content

Conversation

@mrashutoshnigam
Copy link
Contributor

Code Quality: Refactor Localization Strings in Archive Compression and Decompression Actions

This pull request aims to improve code quality and maintainability in the Files App by centralizing localization strings for archive compression and decompression actions. The changes replace direct string literals with references to a new Strings class, enhancing consistency and streamlining future updates and localization efforts.

Closes #16718

Changes Made

  • Created a new Strings class to centralize localization strings for archive-related actions.
  • Refactored localization strings in the following actions:
    • CompressIntoArchiveAction
    • CompressIntoSevenZipAction
    • CompressIntoZipAction
    • DecompressArchive
    • DecompressArchiveHere
    • DecompressArchiveHereSmart
    • DecompressArchiveToChildFolderAction
  • Updated the ComputeLabel method in DecompressArchiveToChildFolderAction for consistent localization.
  • Replaced string literals with corresponding string constants throughout the affected classes.

Benefits

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

Testing Steps

  1. Open Files App.
  2. Locate or create archive files (zip, 7z, etc.) for testing.
  3. Right-click on files/folders and check the compression options (Compress, Compress to ZIP, Compress to 7z).
  4. Right-click on archive files and verify all decompression options (Extract, Extract Here, Extract to [ArchiveName]).
  5. Perform compression and decompression actions to ensure functionality and correct string display.
  6. Change the application language in settings and repeat steps 3-5 to verify localization.
  7. Check for any visual inconsistencies or errors in the displayed strings.
  8. Verify that the ComputeLabel method in DecompressArchiveToChildFolderAction works correctly for different archive types.

Additional Notes

  • This change does not alter any functionality but improves code maintainability for archive-related actions.
  • Code reviewers should ensure all string literals in the affected classes have been replaced with references to the new Strings class.
  • Special attention should be given to the ComputeLabel method in DecompressArchiveToChildFolderAction to ensure it handles different archive types correctly.
  • Verify that the changes do not introduce any regression in existing archive compression and decompression functionality.

Refactor localization strings in archive compression and
decompression actions to utilize a new `Strings` class.
This change replaces direct string literals with references
to the centralized resource management, enhancing
maintainability and consistency across the application.
Affected classes include `CompressIntoArchiveAction`,
`CompressIntoSevenZipAction`, `CompressIntoZipAction`,
`DecompressArchive`, `DecompressArchiveHere`,
`DecompressArchiveHereSmart`, and
`DecompressArchiveToChildFolderAction`. The
`ComputeLabel` method in `DecompressArchiveToChildFolderAction`
has also been updated for consistent localization.
@mrashutoshnigam mrashutoshnigam changed the title Code Quality: Update localization to use centralized Strings class Code Quality: Update localization to use centralized Strings class 4 Mar 2, 2025
Copy link
Contributor

@Lamparter Lamparter left a comment

Choose a reason for hiding this comment

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

@mrashutoshnigam this PR is identical to #16885

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 Mar 2, 2025
@yaira2 yaira2 merged commit 470de08 into files-community:main Mar 2, 2025
6 checks passed
@mrashutoshnigam
Copy link
Contributor Author

@Lamparter The Other PR contains changes of this one as well as additional one.

@Lamparter
Copy link
Contributor

I understand that, why did you create multiple?

@0x5bfa
Copy link
Member

0x5bfa commented Mar 2, 2025

It does not matter. @mrashutoshnigam thanks a lot for doing this:)

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

4 participants