The CreatorCon Call for Content is officially open! Get started here.

Self service portal: Add language option on login page

lomouhamadou
Kilo Guru

Hi all,

Is it any simple way on the new Self service portal for adding the language option on the login page as we have on the backend?

thanks in advance

Regs,

Lô Mouhamadou

1 ACCEPTED SOLUTION

brett_karl
ServiceNow Employee
ServiceNow Employee

I completed a widget solution that ties into the Service Portal Header.



  1. Import the widget record that is attached to this reply
  2. Navigate to your header
  3. Find the following code in the Body HTML Template:

<ul ng-if="::user.logged_in" class="nav navbar-nav">


              <!-- chat, avatar, and logout -->


              <li ng-if="::data.connect_support_queue_id"><a href ng-click="openPopUp()">${Live Chat}</a></li>


         


              <li class="dropdown hidden-xs">


                  <a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown">


                      <span class="navbar-avatar"><sn-avatar class="avatar-small-medium" primary="userID" /></span>


                      <span class="visible-lg-inline">{{::user.name}}</span>


                  </a>



        Add the following code (to line 4):


<li><sp-widget widget="data.languagePicker"></sp-widget></li>



Navigate down to Server Script and add the following line.



  data.languageSelector = $sp.getWidget("language-picker", {});



The end result will look like this:


Screen Shot 2016-08-19 at 2.50.27 PM.png


Please let me know if you any more help!


View solution in original post

44 REPLIES 44

Hi,

I have the same problem of sinanbulut, could someone help to get this work also in London release?

Thanks

Alberto

Hi,

Please note that the only way I managed to make it work was to make the naming identical!

<li><sp-widget widget="data.languageSelector "></sp-widget></li>

  data.languageSelector = $sp.getWidget("language-picker", {});

Otherwise very useful.

Hi,

I do have the same requirement. Can you help me on the same. I have configured the widget but I cant able to know how to add it in the header menu?

 

 

Thanks

monu1
Giga Contributor

Hi Brett,

 

The same code is not working in IE browser  but working fine in Google Chrome.

lomouhamadou
Kilo Guru

Hi guys,




I managed to make the language picker option works for non logged user and without error.


Here is how it works




HTML PART OF THE WIDGET


I have a div with a select for all the 3 languages We are using


When the language changes I call the function getLanguage from the client script part of the widget



<div class="list-group-item">
              <label for="language" class="sr-only">${Language}</label>
              <select   id="language" ng-model="c.data.language" ng-change="getLanguage(c.data.language)" class="form-control no-border">
                  <option value="en">English</option>
                  <option value="nl">Dutch</option>
                  <option value="fr">French</option>
              </select>
          </div>



CLIENT SCRIPT PART OF THE WIDGET



$scope.getLanguage=function(language) {


                 


              c.server.update();


         


                $window.location.href='?id=hr_login';


              }




The c.server.update() refresh the value of the language in the server script function that makes the langague change






SERVER SCRIPT PART OF THE WIDGET



setLanguage(input.language);


      function setLanguage(language) {


             


                var util = new I18nUtils();  


      util.setLanguage(language);  


             



                     


              }




Hope this help ypu out mates.


Please, do not forget to mark this post as "Correct answer" so other users can enjoy it as well.