Skip to content

Conversation

knguyen1
Copy link
Contributor

@knguyen1 knguyen1 commented Oct 11, 2025

WIP: needs testing

Summary

  • This is a…
    • Bug fix
    • Feature addition
    • Refactoring
    • Minor / simple change (like a typo)
    • Other
  • Describe this change in 1-2 sentences: Extends name translation functionality to include album titles and track names in addition to existing artist name translation. Users can now independently toggle translation for artist names, album titles, and track titles using their preferred locales and script exceptions.

Problem

Currently, Picard only supports translating artist names to user-preferred locales. Users who want localized album and track titles must manually edit metadata or rely on external tools. This limits the usefulness of MusicBrainz's alias data for non-artist entities.

Solution

Core Changes:

  • Refactored translation logic in mbjson.py into small, testable helper functions
  • Added _find_localized_alias_name() to select aliases for non-artist entities (albums, tracks)
  • Extended release_to_metadata() to apply album title translation from release aliases
  • Extended recording_to_metadata() to apply track title translation from recording aliases
  • Script exception logic now applies to album and track translations as well

Configuration:

  • Added translate_album_names and translate_track_titles boolean settings
  • All three translation toggles (artist/album/track) are independent and share the same locale preferences and script exception rules

UI Updates:

  • Reorganized metadata options page with clearer grouping of translation controls
  • Changed checkbox labels to be more concise ("Artist names", "Album titles", "Track titles")
  • Updated script exception label to be generic ("Ignore name translation...")

Testing:

  • Added comprehensive test suite in test_mbjson_translations.py covering helper functions and translation behavior
  • Added conftest.py to provide defaulting config fixture for all tests, preventing KeyError with new settings

Action

Additional actions required:

  • Update Picard documentation (please include a reference to this PR)
  • Other (please specify below)

Documentation should be updated to describe the new album and track title translation options and how they interact with locale preferences and script exceptions.

… titles

- Introduced new settings to enable translation of artist names, album names, and track titles based on user preferences.
- Implemented a function to find localized alias names, enhancing metadata accuracy.
- Updated UI components to include checkboxes for the new translation options, improving user experience.
- Adjusted metadata processing functions to utilize the new translation settings when applicable.
- Added functions to manage script exceptions for artist name translation, allowing for more granular control over when translations are skipped based on detected scripts.
- Updated the metadata processing functions to incorporate these new checks, ensuring that translations respect user-defined script exceptions.
- Modified UI components to improve layout and clarity for translation options, enhancing user experience.
- Adjusted related documentation and comments for better understanding of the new functionality.
…ity and efficiency

- Renamed and reorganized functions to improve the handling of localized alias names, enhancing code readability.
- Introduced a new function to build maps of full and root locales from alias entries, streamlining the localization process.
- Updated the existing function to select localized aliases based on preferred locales, ensuring a clear preference order for matches.
- Enhanced type annotations and documentation for better understanding and maintainability of the code.
- Streamlined the logging function for detected scripts by consolidating log message construction.
- Improved clarity by directly formatting the output string and handling cases with no detected scripts more efficiently.
- Enhanced documentation for better understanding of the logging behavior.
- Improved the `_build_alias_locale_maps` function to prioritize explicit root-locale aliases over derived values, ensuring more accurate locale mapping.
- Introduced a comprehensive test suite for alias localization, covering various scenarios to validate the functionality of the updated mapping logic.
- Enhanced type annotations and documentation for better clarity and maintainability of the code.
@zas zas requested review from phw and zas October 12, 2025 10:15
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.

1 participant