Forum Discussion

zoe's avatar
zoe
Mentor
14 years ago

Help needed on using Freemarker to display languages

We are trying on using Freemarker to display the language.

 

Our community has 3 languages, the default language is English

English page, display Spanish and German

Spansh page, display English and German

German page, display English and Spanish

 

Here is the code we are using

<#if page.name == "CategoryPage" && coreNode.id == "Spanish">
<li><a href="/community/?category.id=English">English</a></li>
<li><a href="/community/?category.id=German">Deutsch</a></li>
<#elseif page.name == "CategoryPage" && coreNode.id == "German">
<li><a href="/community/?category.id=English">English</a></li>
<li><a href="/community/?category.id=Spanish">Espanol</a></li>
<#else>
<li><a href="/community/?category.id=Spanish">Espanol</a></li>
<li><a href="/community/?category.id=German">Deutsch</a></li>
</#if>

 

It display what we intended on the language category page, but the subcategories, board, and thread doesn't inherit this logic.

 

Please help if anyone has an idea.

  • DougS's avatar
    DougS
    Khoros Oracle

    Hi Zoe,

     

    You might want to try moving the link markup into a couple of text keys and creating different text key entries for each language.  For example, your markup might look like this:

     

    <li>${text.format("custom.language_select.1.link")}</li>
    <li>${text.format("custom.language_select.2.link")}</li>

     

    Then, you would go into Lithium Studio, go to the Text Editor tab, click the Search button, then add in entries for the two text keys you added to your component for english:

     

    custom.language_select.1.link = <a href="/community/?category.id=Spanish">Espanol</a>
    custom.language_select.2.link = <a href="/community/?category.id=German">Deutsch</a>

     

     Next, select Spanish from the Language drop-down and add the same text keys in for Spanish:

     

    custom.language_select.1.link = <a href="/community/?category.id=English">English</a>
    custom.language_select.2.link = <a href="/community/?category.id=German">Deutsch</a>

     

    Finally, select German from the Language drop-down and add the same text keys in for German:

     

    custom.language_select.1.link = <a href="/community/?category.id=English">English</a>
    custom.language_select.2.link = <a href="/community/?category.id=Spanish">Espanol</a>

    Now the markup will always render correctly for Spanish and German wherever they are set (be it a category, sub-category, or board) and will fall back to English if the language is not Spanish or German.

     

    I hope that helps!

     

    -Doug

     

    • RobbL's avatar
      RobbL
      Lithium Alumni (Retired)

      Hi Zoe,

       

      To find additional help and support with questions related to Freemarker you can also check the part of the Lithosphere that is designed for developer questions. Just click on the right-most tab labeled "Develop" in the navigation bar towards the top of the page.