Skip to main content
Frances Silva
Lead Developer
Asked a question 8 months ago

For static text like content type name, topic name, group name, and etc, how can I make sure it gets translated when the user's account language is something other than my community language?

Where am I?

In Tribe you can ask and answer questions and share your experience with others!

Eli Tribe TEAM
Customer Support Manager at Tribe

Hi @Frances Silva12. This is a very good question. 

As you know, when the user changes the language preference for his/her profile account, we automatically translate the options and buttons in the community. So the interface gets translated. However, there are buttons/sections in the community, like the name of the topic, the name of the groups, the naming for the content-type, which are manually created by you or your teammates. So, as these are static names, they are not supposed to get translated when the user changes his/her profile account language. 

That being said, there is no native way to translate the static namings, but there is a workaround for it that needs a little coding from your side. 

As an example, imagine that you have changed the name for the "Post" content-type as "A". 
The preset language for the entire community from the admin panel is "English". 
You want to make sure that when a user changes his preferred language to French, the naming "A" gets changed to "B" which is understandable for French speakers. 

To do that, you can add this Javascript to the Admin Settigns> Theme> Advanced Settings> add the following Javascript to <head> tag:

Tribe = {
  onPageChange: function(pathname) {
    if (document.querySelector('html').getAttribute('lang') == 'fr')
      if (document.querySelector('.content-input-tab-post')) {
        document.querySelector('.content-input-tab-post').innerHTML = 'Publier'
      if (document.querySelector('.content-input-submit')) {
      document.querySelector('.content-input-submit').innerHTML = 'Publier'

However, the problem with this method is that it'll take around 100 milliseconds for it to update the text.

A better method might be using CSS to replace text as following:

`html[lang="fr"] .content-input-tab-post` as the selector.