ExportXMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Normal
    • None
    • Affects Version/s: None
    • Component/s: Back-end

      Autocomplete (/ws/js) shows the entity name. If the entity has a primary alias in the interface language, the result can also include a primaryAlias. The code that picks it is _with_primary_alias in lib/MusicBrainz/Server/WebService/JSONSerializer.pm. It reduces the interface language and each alias locale with this substitution:

      s/_[A-Z]{2}/_/
      

      The substitution changes fr_CA to fr_ and ja_JP to ja_. A second substitution removes the trailing _ from the interface language. Neither substitution changes es_419 or zh_Hant.

      If the reduced locale of an alias matches the reduced interface language, with or without a trailing _, the alias gets a preference. English aliases get a lower preference. Other aliases get no preference.

      For an es_419 interface, an es alias therefore gets no preference. For a zh_Hant interface, zh and zh_TW aliases get no preference either. If the entity also has an en alias, autocomplete shows the English alias. If it does not, autocomplete shows no primaryAlias.

      The artist page uses find_best_primary_alias in lib/MusicBrainz/Server/Data/Utils.pm. That function compares the first two characters of the locale, so it picks the es or zh alias. Autocomplete and the artist page therefore show different additional aliases for the same entity.

      The es_419 case exists today. After MBS-14482, zh-Hant can be enabled, and then the zh_Hant case occurs too.

      Steps to reproduce

      The artist Berliner Philharmoniker has a primary es alias "Orquesta filarmónica de Berlín" and a primary en alias "Berlin Philharmonic Orchestra". It has no es_* alias. Both aliases are not ended.

      1. Set the interface language to Spanish (Latin America), es-419.
      2. Open the artist page. The header shows "Berliner Philharmoniker (Orquesta filarmónica de Berlín)".
      3. Type "Berliner Philharmoniker" into an artist autocomplete field.

      Expected: The result shows the Spanish alias, as the artist page does.
      Actual: The result shows "Berlin Philharmonic Orchestra". The response of /ws/js/artist?q=Berliner%20Philharmoniker has "primaryAlias":"Berlin Philharmonic Orchestra".

      The same steps with zh-Hant and an artist with a primary zh or zh_TW alias give the same result.

      These results come from the two functions with primary, non-ended aliases:

      Interface language Alias locales Autocomplete find_best_primary_alias
      es_419 es, en en es
      es_419 es none es
      zh_Hant zh, en en zh
      zh_Hant zh_TW, en en zh_TW
      fr_CA fr, fr_CA, en fr fr_CA
      es_419 es, es_419, en es_419 es_419

      Suggested fix

      The function already has this comment:

      # TODO: Consider updating this function to call find_best_primary_alias().
      

      Consider reusing find_best_primary_alias so both paths follow the same selection rules. This changes more than the fallback for es_419 and zh_Hant:

      • It ignores ended aliases. The serializer does not.
      • It prefers an exact locale match. The serializer prefers the base language: for fr_CA, it picks a fr alias over a fr_CA alias.

      The intended order is an exact match first, then the base language, then English. A change to $munge_lang alone cannot give that order, because it removes the difference between the locales.

      Open question

      For a zh_Hant interface, a zh alias can be in Simplified Chinese. find_best_primary_alias already accepts it, so this ticket only asks the two code paths to agree. A script-aware preference (zh_Hant, then zh_TW or zh_HK, then zh) can be a separate ticket.

            Assignee:
            Unassigned
            Reporter:
            Shen-Ta Hsieh(BestSteve)
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                Version Package