Forum Discussion

bma's avatar
bma
Mentor
11 years ago

How to get text key localization value by locale/language or node ID with REST or Endpoint?

Hi,

 

I have a community with different language preferences set for each sub-category (e.g. French language category, German language category, Chinese language category, etc., configured via Admin > Users > Profile Defaults > Language).

 

I'm attempting to retrieve and display text key values of a specific sub-category at the community level.

 

I'm able to read a locale code (?) from /users/self' or a node's 'profile.language' setting:

rest('/users/self/settings/name/profile.language').value
rest('/categories/id/${catId}/settings/name/profile.language').value

 

I can also use the 'text' Freemarker context object' text.format() to retrieve the value of a text key relative to the current node's (e.g. community at the community level) configured language (and/or user's selected language).

 

  1. Is there a way to retrieve a specific text key localization via REST or Endpoint given a locale code/language or node ID?
  2. Is there a separate setting or direct way to determine if a user is not using the default configured language?
  3. What is the difference between the 'profile.language' and 'config.language' setting?

Thanks!
Ben

 

  • YuriK's avatar
    YuriK
    Khoros Expert

    Hey bma,

     

    1) Currently the text.format call doesn't allow you to specify the locale to use yourself. It will do whatever is most reasonable based on user and node settings. I would suggest you file it as an idea in our idea board as I see this as a good enhancement to have.

    2) I'm assuming by default configured language you mean the community default language? In which case you can use the community settings api to determine what language setting is set on the community and then compare it to the user setting. (rest('/settings/name/profile.language').value) You can also use the settings freemarker context object to figure out what will be the derived setting (the setting that will be used) for the current user at the current node.

    3) From what I can tell 'config.language' is no longer used and you should always be using 'profile.language'

     

    Hope this helps,

     

    Yuri