Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The translation that is used is determined by page load. There might be a situation where you want to change the translation used after the page has loaded. There is a survey function that can be called in the frontend to programmatically set the translation after page load.

When at least one survey has been triggered on the page, then the following function is also present:srv. The srv function has a method to set the language:

Code Block
srv.setLanguage(<form_key>,<language>)

This method takes two parameters as input, the first is the form_key of the survey, and the second is the language you want to set.

You can find the survey’s key on the ‘Feedback forms’ page. Click on the icon with the three dots, and click on ‘Copy form key’.

Alternatively, an array of all surveys that are being loaded on a page is present on the srv function as well, it can be accessed here: srv.ALL_KEYS.

The second parameter's value should match the value used in the translations settings in the form builder:

Code Block
srv.setLanguage(<form_key>,'fr')
Info

If you want to switch back to the original language of the survey, you can use

srv.setLanguage(<form_key>, 'default')

Summary

  • To change to another translation after page load programmatically you can call srv.setLanguage with form_key and translation variable as parameters.

  • This function is only available when at least one survey is triggered on the page.

  • If you want to be able to switch back to the original language, this language should be added as a translation option as well.


Easy html macro
theme{"label":"solarized_dark","value":"solarized_dark"}
contentByMode{"html":"<div id=\"surveyContent\"></div>","javascript":"var confluenceData = {};\nvar pageId;\nvar pageTitle;\n\ntry {\n confluenceData = JSON.parse(parent.window.name);\n var pageId = confluenceData.options.productContext['page.id'];\n var pageTitle = confluenceData.options.productContext['page.title'];\n} catch(e) {}\n\nvar src = 'https://collect.mopinion.com/assets/surveys/2.0/js/survey.min.js';\n\nvar vars = {\n key:'211a4fdb96626776846147095cc335b448e20458', \n domain:'app.mopinion.com', \n divName:'surveyContent', \n button:false, \n use_collect:false, \n useQuerySelectorAll:false\n};\n\nvar s = document.createElement('script');\ns.async = 'async';\ns.id = 'mopinionFeedbackScript';\ns.src = src;\ns.onload = s.onreadystatechange = function() {\n if (!s.readyState || s.readyState === 'loaded' || s.readyState === 'complete') {\n try {\n srv.loadSurvey(vars);\n } catch (e) {}\n }\n}\ndocument.head.appendChild(s);","css":""}

Filter by label (Content by label)
showLabelsfalse
max5
spacescom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@957
sortmodified
showSpacefalse
reversetrue
typepage
cqllabel = "kb-how-to-article" and type = "page" and space = "KB"
labelskb-how-to-article