Translatable user added tags

I have a particular use-case.

Users want to be able to:

  • Create any number of tags
  • Associate any number of these tags to pages (through a query on a tag, select, etc field)
  • Translate these tags for each language in the site

But what users don’t want to do is having to add each tag to each page in each language, three of them in this site (a cumbersome process indeed)

They would like to add a tag to a page, and have it added in every language.

Put in another way they expect tags to be linked across languages, as a regular field would be: you create a field in one language, and translate it in the other language, but you don’t have to create each field in each language: they are linked.

But as far as I recall entries in fields such as tags or structure cannot be translated individually. We can add different entries to tags or structure in each language, but they are not linked, so adding a tag to a page won’t add the corresponding tag in a secondary language.

If the tags were static, I could use something like a select field, offering translated options. Although I believe value is not translated, only visible option text, I could nevertheless use language variables to show the correct language in the frontend.

But for dynamic, user-added, tags or categories, I can’t see a workaround.

Am I correct about this?

Anything I could use instead?

Thank you

What you could do:

  1. Create a structure field with fields for the tags in each language. This can be done either in the site blueprint or in the parent page of the pages where the tags are used, up to you depending on use case.
  2. In the page blueprint, where tags should be assigned, use a tags’ field but make it non-translatable (translate: false). This field should query the structure field with the defined tags.
  3. In the frontend, pull in the translations from the structure field.

Thanks,

Do you mean to have, in the structure field, a field for each language ? Such as:

fields:
  tags:
    type: structure
    fields:
      tagen:
        type: text 
      tages:
        type: text       
      tagca:
        type: text 

… and possibly translate: false on this field too (as it already has fields for each lang) ?

Then use the tags fields on the pages querying this structure ? I guess querying only the first field of each entry, if that is possible.

Then in the frontend use the tags field stored value to loop over the structure field, match entry, and fetch the translations ?

Yes, exactly, you don’t want to translate these.

Yep!

Exactly.

Find the entry that matches the value and then get the right value. I’d use underscores or just language code for the field names in the structure to make it easier.

fields:
      en:
        type: text 
      es:
        type: text       
      ca:
        type: text 

Ok that’s a practical workaround thank you.

I am realizing now that a second workaround would be to use either a structure or a tags field to define possible tags, and just ask them to keep the same number of tags in the same order across languages, something like:

fields: 
  test:
    type: tags
    help: Keep the tags in the same order across languages

… then using tag order to fetch from each language in the frontend. Although of course this seem much more fragile than your solution.

Thanks again

I think a structure field is more reliable.