language toggle

In SharePoint Foundation 2010, when someone navigates to a multilingual website, the website uses the Accept-Language header that the client browser sends with the HTTP request to determine the language in which to render the user interface. If the website does not support any of the languages specified by the browser, the default language is used as the display language


But In SharePoint 2013 the language switcher drop down is removed ... So we have tried to implement our own switcher with same concept in SharePoint 2010. Reference the Changing the Display Language - But trying to add the JavaScript was useless.

To package this solution we created Web feature named « ToggleLanguage Feature ». When you activate the feature, a custom action will be added to the standard menu of SharePoint. Each Custom action contains one language of the alternate languages of the site. In figure 1 we have three languages: French, English and German.

 Figure 1: Custom action for each language

Figure 1: Custom action for each language

The click in the button language, add cookie named “ToggleLanguage” in the current document. The cookie contains the language code of the culture. Example en-US if you click in English.

Fig 2: Feature Activated

Fig 2: Feature Activated

Fig 3: Script action

Fig 3: Script action


When you deactivate the feature, all the custom action will be deleted from custom menu.

Deactivate feature

Fig 4: Deactivate feature


Custom action deleted

Figure 5: Custom action deleted


Changing Language

The trick is the new SharePoint model for changing the display language  is by checking the user's language preferences ... Then adding those languages to the request header in the Accept-Language tag i.e. fr-FR,en-US. So we tried another approach ... Using an HTTP Module which interrupts the request in a very early stage.

Http module

Figure 6: Http Module

OK ... we will not reinvent the wheel ... The game plan is to interrupt the request and check for the cookies value - Assuming we have a cookie preserving the current selected language - Adding the selected language at the to the request header using an HTTP Handler, Then setting the current thread culture to the selected language, By implementing the PreRequestHandlerExecute event handler.

Http module code source

Figure 7: HttpModule code source

Finally to install this module in Sharepoint, you must configuring the web.config in the rootweb of the web application.

  1.        Configuration > System.web > httpModules

    <add name="ToggleLanguage" type="ToggleLanguage.Helper.HttpModule, ToggleLanguage, Version=, Culture=neutral, PublicKeyToken=fe42bef4f6e9818f" />
  2.             Configuration > System.webServer > modules
    <add name="ToggleLanguage" type="ToggleLanguage.Helper.HttpModule, ToggleLanguage, Version=, Culture=neutral, PublicKeyToken=fe42bef4f6e9818f" />


Conclusion: In this solution we worked with the custom action. But you can use any other method to navigate between the languages. For example, adding delegate control in the master page to create cookies.



Last edited May 5, 2014 at 8:54 AM by saberghanmi, version 4