I am trying to add a Change Language menu item to the top navigation header in Confluence. The code below works. However, it only detects the browser locale instead of the language specified within the users profile.
How can I detect the user language via AJS?
<script> AJS.toInit(function(){ var browserLang = navigator.language || navigator.userLanguage; if(browserLang =="en-CA"){ AJS.$('.aui-header-secondary .aui-nav').append('<li><a href="/cra/language/languageswitch.action" class=" aui-nav-imagelink">English</a></li>');} else { AJS.$('.aui-header-secondary .aui-nav').append('<li><a href="/cra/language/languageswitch.action" class=" aui-nav-imagelink">French</a></li>'); } }); </script>
I found the answer to be AJS.params.userLocale
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.