Problem/Motivation

I have been using the glossary feature for a while and it is working well. Most langcodes in Drupal have an equivalent langcode in Google. E.g. japanese, korean. However, I'm now working on a Hong Kong site with langcode zh-hant-hk. Google does not have a based model for the Hong version of traditional Chinese. It just uses zh-TW (Taiwan) See https://cloud.google.com/translate/docs/languages.

So in my Drupal website I have setup zh-hant-hk and set the remote target to zh-TW per the docs. This means however, that due to the current code, it's not possible to set a specific glossary for zh-hant-hk, because the glossary mapping uses the remote target langcode to check if a glossary exists, not the local drupal langcode.

Our hong kong team needs to be able to setup a hong kong specific glossary for certain terms.

Steps to reproduce

Try and setup a language zh-hant-hk, map it to zh-TW and you will notice that currently the glossary won't work, because it uses getRemoteTargetLanguage for looking up the glossary.

Proposed resolution

I have cleaned up the arguments passed to executeTranslation as there are too many for yet another argument, so we now have a $translation_context array with all the meta data for the translation. A new language_to_local which represents the Drupal langcode of the translation and then the language_to_remote which is the base model that Google is going to use.

I also fixed a bug where the glossaries weren't being passed recursively with longer text.

Remaining tasks

I've tested it

User interface changes

N/A

API changes

N/A

Data model changes

N/A

CommentFileSizeAuthor
#3 3528323_3.patch5.6 KBachap
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

achap created an issue. See original summary.

achap’s picture

Status: Active » Needs review
StatusFileSize
new5.6 KB

Attaching a patch from the MR for composer

  • kallado committed 5ffff73d on 1.0.x
    [#3528323] feat: Allow to specify glossary for Drupal langcode with no...

kallado’s picture

Status: Needs review » Reviewed & tested by the community

@achap commited

kallado’s picture

Status: Reviewed & tested by the community » Fixed

Fixed in 1.0.5

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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