Get tag title.fr in HTL/Sightly | Community
Skip to main content
Level 3
October 14, 2022
Solved

Get tag title.fr in HTL/Sightly

  • October 14, 2022
  • 3 replies
  • 2228 views

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.

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by BrianKasingli

@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.  


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

3 replies

Saravanan_Dharmaraj
Community Advisor
Community Advisor
October 14, 2022

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.html?lang=en#tags-in-different-languages

joerghoh
Adobe Employee
Adobe Employee
October 15, 2022
<h1>${properties.jcr:title.fr}</h1>

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

MoiezMaAuthor
Level 3
October 17, 2022

@joerghoh 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. 

 

 

 

 

BrianKasingli
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
October 17, 2022

Hi @moiezma,

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).

MoiezMaAuthor
Level 3
October 17, 2022

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

 

 

 

BrianKasingli
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
October 17, 2022

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

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