Hi guys! Our community has two languages. You can change the language just by clicking the link in the header of each page.
Where can I add the logic to change the category name and description depending on language selected by the user?
First you have to get the user language by using the following query and then use conditional statement.
<#assign getUserLang =restadmin("/users/id/12/profiles/name/language").value /> <#if getUserLang == "en"> // Your code here <#elseif getUserLang == "US"> //Your code here <#else> //Your code here </#if>
Let me know if it works.
I already got the same code in a couple of custom components. My question was more about where I have to place this code to get it work with categories titles/descriptions?
So can I use two different languages for categories titles/descriptions and switch it based on the language chosen by the user?
It's relatively easy to replace the "PageTitle" component on the ForumPage and CategoryPage layouts with a custom component that shows different titles depending on user language setting.
The bigger challenge though is the board list component that you would need to completely re-created to show different titles and descriptions. There's currently no support for different localized names. The reason for that is that it's generally against best practice to combine multi-language content on the same node. You'd rather set up dedicated categories and nodes within them for each language. The only exception might be very similar language, e.g. Ukrainian and Russian that you might want to combine within the same boards.
See this related discussion: https://community.lithium.com/t5/Support-Forum/Can-a-Node-Title-be-a-Named-Text-Key/m-p/281433