We have web-part made on jQuery and HTML. This web-part will be use in two different language.

In SP 2013 on-premise we use to create wsp which contains resx file for each different language, but as we know that we cannot deploy wsp to the SharePoint Online, can somebody help how we can do on SharePoint online


How about using _spPageContextInfo.currentUICultureName, or html[lang] (lang property of HTML node of the page). I've preferred html[lang] as it is available immediately. Would either of them work for you?

Define resources like

myResStrings = {
  "en-US": {
    "login": "Login"
  "fi-FI": {
    "login": "Kirjaudu sisään"

and load resources (in case of HTML tag) in some "main" javascript file like

LanguageSettings = myResStrings[document.getElementsByTagName('html')[0].getAttribute("lang")];
//If Language not found revert to English US
if (!LanguageSettings) {
    LanguageSettings = myResStrings["en-US"];

And finally get localized string in JS with LanguageSettings.login.

| improve this answer | |

The recommended way for Web part development in SharePoint Online is using SPFX. https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/build-a-hello-world-web-part

When you generate the code for your web part you automatically get Typescript and JavaScript code for localization.

| improve this answer | |

For SPO, i suggest using Multiple Language User Interface (MUI) for creating sites withdifferent languages.

With the MUI feature, you can display the following user interface elements in different languages:

  • Web Parts
  • Site title and description
  • SharePoint default menus and actions
  • Default columns
  • Custom columns (list or site)
  • Navigation bar links
  • Managed metadata services

Note: The MUI feature changes only the display language for default UI elements. Custom UI elements that you have added are not translated. Which means you need to proivde your own display language for custom UI elements.

You can review Introduction to multilingual features for more info.

| improve this answer | |
  • Hi, I know very well concept of site variant and we have already created two MUI website already. Now our custom web-part have some labels which I want to supply our own translation. How we can do that !! – Milind Aug 29 '18 at 9:10
  • @Milind, are these labels you want to change are custom labels or sharepoint labels ? – NaaHCat Aug 29 '18 at 9:57
  • it is custom Label – Milind Aug 29 '18 at 11:03

On SharePoint Online, what you use instead of localized webparts depends whether you intend to use Modern or Classic pages.

On Classic, what is recommended is using App parts. There are two options for those, SharePoint hosted and provider hosted. If it is provider hosted, then the app part will be running in .NET on another server; you can use resx files there, and the user's language is passed to your aspx among the parameters.

If it is SharePoint-hosted, that is to say all JavaScript, then the way to localize those is with JavaScript resource files, with names like "Resources.en-US.js". Details here: https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/localize-sharepoint-add-ins

You can use the resource tokens from SharePoint's own resx files, but you can't use your own resx files. In your aspx you have it load the correct JavaScript resource file using a line like

<script type="text/javascript" src="../scripts/Resources.<SharePoint:EncodedLiteral runat='server' text='<%$Resources:wss,language_value%>' EncodeMethod='HtmlEncode' />.js"></script>

The "$Resources:wss,language_value" will take the value en-US, or whatever, at run time because it gets it from SharePoint's wss.resx file. Note: app parts run in a separate site in a different domain on the same server, but it will generally inherit the same language as the host site.

Another alternative on Classic pages is to inject JavaScript on a page or in an existing webpart using jslink and client side rendering (CSR). You can inject your JavaScript file plus jQuery if you want. Then in your code you can use a similar technique to load js resource files but using the variable _spPageContextInfo.currentUICultureName. Please note that using html[lang] in JavaScript and CSS is reliable only if you want to use the language of the site, not the language of the user. It is reliable in Modern pages. http://blog.icefire.ca/post/how-to-achieve-language-specific-styling-in-modern-pages

The techniques above only work for Classic pages. For Modern pages, you need to use SPFx webparts. This is getting long, so read this guidance https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/guidance/localize-web-parts

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.