Custom language codes not supported by getMatchingGlossarie()

Created on 29 January 2025, 2 months ago

Problem/Motivation

When working with complex multilingual websites that requires custom language codes to support for example many English, German, Italian and French languages, are these custom languages codes not supported in the DeepL Glossary integration. Even though that they are mapped to DeepL languages in the DeepL provider configuration.

Steps to reproduce

  1. Create a new language named "San Marino - Italian" with the language code sm-it
  2. Adjust the DeepL provider settings and map new sm-it language to Italian.
  3. Create a new glossary with source language English and target language Italian, and add some glossaries.
  4. Create a new node in English.
  5. Request a translation of the new node to "San Marino - Italian"
  6. Choose the DeepL provider and see that no glossaries are listed in the Checkout settings.

Proposed resolution

Adjust the 3 calls to DeeplGlossary::getMatchingGlossaries() in tmgmt_deepl_glossary.module from using the source and target language codes to use the remote source and target language codes.

This change will ensure that we use the mapped DeepL language codes and not the local language codes in Drupal.

🐛 Bug report
Status

Active

Version

2.2

Component

tmgmt_deepl_glossary

Created by

🇩🇰Denmark beltofte Copenhagen 🇩🇰

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @beltofte
  • 🇩🇰Denmark beltofte Copenhagen 🇩🇰

    The proposed resolution is implemented in the issue fork.

  • Pipeline finished with Success
    2 months ago
    Total: 207s
    #409693
  • 🇩🇪Germany SteffenR Germany

    The glossary entities use the available languages provided by the API: https://developers.deepl.com/docs/api-reference/glossaries

    In case of having custom language codes on your site, you should also use ISO 639-1 notation.
    The correct language code for San Marino - Italian would be it-SM (https://localizely.com/locale-code/it-SM/) and not SM-IT, since the San Marino italian is a subset of the original italian language.

    The glossary matching functionality will always take the first two letters based on ISO 639-1 and will use this for its matching logic.

  • 🇩🇰Denmark beltofte Copenhagen 🇩🇰

    Thanks for your input @steffenr!

    I'm aware that it is common to follow the ISO 639-1 notation and it also works fine in most cases, but not in all....

    Our current case is a bit different and not the most common. It is a global multilingual website where each country/market have their own area under one global domain. Each country/market has one or more languages and use language codes in the format country-language e.g. sm-it and sm-en for Italian and English languages for San Marino. We have at 75+ languages configured with fallback and other things. We have for example 20+ country specific English languages configured with fallback to one main English language (eu-en).

    The glossary matching functionality will always take the first two letters based on ISO 639-1 and will use this for its matching logic.

    You could get rid of fixLanguageMappings() completely if the code moved from the local language pairs to the remote language pairs in the job entity, as the remote language pairs will always use the format expected by DeepL and that is stored in DeepL's glossaries.

  • Pipeline finished with Success
    2 months ago
    Total: 171s
    #410065
  • Pipeline finished with Skipped
    2 months ago
    #411403
  • 🇩🇪Germany SteffenR Germany

    @beltofte: I just checked the MR and its working fine.
    Using the remote language mappings really makes sense in getMatchingGlossaries. I just ask myself "why have i solved it the other way?" ;)

    Thanks for your contribution!

  • 🇩🇪Germany SteffenR Germany
    • steffenr committed bdb37d9c on 2.3.x
      #3503212: use remote language codes for retrieving matching glossaries
      
  • 🇩🇰Denmark beltofte Copenhagen 🇩🇰

    Unfortunately we cannot use the same logic in 2.3.x, where the Source/ Target languages are retrieved via the API.
    In case of English we would get EN-GB and EN-US.
    So we will still need to fix the mapping manually - even if we get use the remote language mappings. But since we are using remote language mappings custom langcodes are working also.

    Interesting. I'm quite busy this week and next week, but would be happy to help with testing our big multilingual installation on 2.3.x mid/ultimo February if it is not too late for your rollout plans.

  • 🇩🇪Germany SteffenR Germany

    @beltofte: Thanks for helping out.
    I planned to release an alpha release mid/ end of february. Right now i'm also busy doing other projects.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024