Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Get tag title.fr in HTL/Sightly

Avatar

Level 2

Does anyone know if we can get tag title in different languages in HTL/Sightly? I'm able to get the tag title and name but not the title.en and title.fr value.

 

snowwhite92_0-1665779195616.png

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Cool makes more sense, have you tried:

Tags in Different Languages

As described in the documentation for administering tags, in the section Managing Tags in Different Languages, a tag titlecan be defined in different languages. A language sensitive property is then added to the tag node. This property has the format jcr:title.<locale>, e.g. jcr:title.fr for the French translation. <locale> must be a lower case ISO locale string and use “_” instead of “-”, for example: de_ch.

When the Animals tag is added to the Products page, the value stockphotography:animals is added to the property cq:tags of the node /content/geometrixx/en/products/jcr:content. The translation is referenced from the tag node.

The server-side API has localized title-related methods:

  • com.day.cq.tagging.Tag

    • getLocalizedTitle(Locale locale)
    • getLocalizedTitlePaths()
    • getLocalizedTitles()
    • getTitle(Locale locale)
    • getTitlePath(Locale locale)
  • com.day.cq.tagging.TagManager

    • canCreateTagByTitle(String tagTitlePath, Locale locale)
    • createTagByTitle(String tagTitlePath, Locale locale)
    • resolveByTitle(String tagTitlePath, Locale locale)

In AEM, the language can be obtained either from the page language or from the user language:

  • to retrieve the page language in a JSP:

    • currentPage.getLanguage(false)
  • to retrieve the user language in a JSP:

    • slingRequest.getLocale()

Building Tagging into an AEM Application | Adobe Experience Manager

View solution in original post

8 Replies

Avatar

Level 8

The server-side API has localized title-related methods:

  • com.day.cq.tagging.Tag

    • getLocalizedTitle(Locale locale)
    • getLocalizedTitlePaths()
    • getLocalizedTitles()
    • getTitle(Locale locale)
    • getTitlePath(Locale locale)

Check this out

https://experienceleague.adobe.com/docs/experience-manager-64/developing/platform/tagging/building.h...

Avatar

Employee Advisor
<h1>${properties.jcr:title.fr}</h1>

But I think you have a different problem. So would you mind to elaborate your question a bit?

Avatar

Level 2

@Jörg_Hoh yes of course. Under tagging author have an option to add translation for EN and FR tag but in slightly/HTL when we pull the tag by title property it doesn't give the correct translation. I believe because the tag has multiple properties and we need to pull correct property based on the language. I have tried properties.jcr:title.fr but it doesn't pull anything. based on all my research I think it's not possible to pull it in HTL. I'll have to use tagManager to write some logic to pull correct info. but let me know if you are aware of a better solution. 

 

snowwhite92_3-1666021661759.png

 

 

snowwhite92_2-1666021356717.png

 

Avatar

Community Advisor

Hi @snowwhite92,

From looking at your configurations, how you engineered the pageProperties for jcr:title.en vs jcr:title.fr, looks unrealistic and a bad solution. It looks like you are trying to serve different languages in the same website structure; I suggest you check out AEM live copies and blueprint; this will help you are your organization be more organized and set up for scalability. Also, take a look at the i18n dictionary key's (its an out-of-the-box solution for AEM).

Avatar

Level 2

@BrianKasingli These are the tag properties not pageProperties. This is how AEM save multiple language tags in AEM. 

 

snowwhite92_0-1666021067303.png

snowwhite92_1-1666021185804.png

 

 

Avatar

Community Advisor

a little more context comes a long way 😉 now we know its tags 😉

<h1>${properties.jcr:title.fr}</h1> (what  said)

 

Avatar

Level 2

@BrianKasingli Thank you for prompt reply. unfortunately it's not that simple. Tags return a list of tags, we can't just directly call it using properties. I have looped over it but it return null. From what it seems I'll have to use tags or tagManager api to get FR tag value.  

Avatar

Correct answer by
Community Advisor

Cool makes more sense, have you tried:

Tags in Different Languages

As described in the documentation for administering tags, in the section Managing Tags in Different Languages, a tag titlecan be defined in different languages. A language sensitive property is then added to the tag node. This property has the format jcr:title.<locale>, e.g. jcr:title.fr for the French translation. <locale> must be a lower case ISO locale string and use “_” instead of “-”, for example: de_ch.

When the Animals tag is added to the Products page, the value stockphotography:animals is added to the property cq:tags of the node /content/geometrixx/en/products/jcr:content. The translation is referenced from the tag node.

The server-side API has localized title-related methods:

  • com.day.cq.tagging.Tag

    • getLocalizedTitle(Locale locale)
    • getLocalizedTitlePaths()
    • getLocalizedTitles()
    • getTitle(Locale locale)
    • getTitlePath(Locale locale)
  • com.day.cq.tagging.TagManager

    • canCreateTagByTitle(String tagTitlePath, Locale locale)
    • createTagByTitle(String tagTitlePath, Locale locale)
    • resolveByTitle(String tagTitlePath, Locale locale)

In AEM, the language can be obtained either from the page language or from the user language:

  • to retrieve the page language in a JSP:

    • currentPage.getLanguage(false)
  • to retrieve the user language in a JSP:

    • slingRequest.getLocale()

Building Tagging into an AEM Application | Adobe Experience Manager