Support language specific entity tokens.

Created on 21 April 2022, almost 3 years ago
Updated 30 April 2024, 12 months ago

Problem/Motivation

We've long wanted this functionality.
I brought it up July 21 2020 🐛 Token for entity reference returns default language instead of translation Needs work

wondering if it would be possible to allow the tokens to process a language suffix in the token to get the specific language value otherwise grab the current interface language

@berdir had this to say July 22 2020 🐛 Token for entity reference returns default language instead of translation Needs work :

The language is passed in as an option, token syntax simply isn't flexible enough to allow arguments like that. Each token has one type and has to pass things to its children.

In response to @berdir, obviously for us wanting this functionality, it should only be enabled when there are multiple languages available so I don't see the argument for concern about the number of tokens. It could be also an optional functionality which could be disabled by default but enableable.

The missing tokens are:

(examples):

  • [term:field_company_code:fr] and [term:field_company_code:nl]
  • [node:field_name:fr] and [node:field_name:nl]

OR, if it's easier to do it this way:

(examples):

  • [node:fr:field_company_code] and [node:nl:field_company_code]
  • [node:fr:field_name] and [node:nl:field_name]

OR maybe we hack something in like this:

(examples):

  • [node_fr:field_company_name] and [node_nl:field_company_name]
  • we could check the token for the string , if it's node_xx , string parse it and set the langcode to xx.

OR hack something like this

  • OR [node:field_company_name_fr] and [node_nl:field_company_name_fr]
  • we could check the token for the string , if it's field_company_name_xx , string parse it and set the langcode to xx.

We need to have standard tokens for things like nodes which are for a specific language. For things like multi-language emails it is not sufficient to simply use the current context language to determine the language of the token value.

So for a token like this: [node:field_shared_node:entity:title], we need something like [node:field_shared_node:entity:title:fr]

not sure the best format for this, just adding langcode to the end seems like it would be difficult to parse as not being for something else. Looking at date tokens as an example they do not seem to worry about this as these are all valid:
date:custom:?
date:format_1
date:format_2

Maybe something like: [node:field_shared_node:entity:title:language:fr] would be preferred?

I have seen a few other language specific token issues and this exact issue reported in one of them but the reply was that it was out of scope of that particular issue - so guessing this hasn't yet been requested in its own issue. Apologies if it has been.

Also, not sure if this would be part of this module or perhaps its own contrib module?

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇨🇦Canada liquidcms

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024