0

How to do Multilingual/Localization support in SharePoint Framework Client Side Webparts?

0

Check the below steps for adding multiple language in SharePoint Framework(SPFx) webparts:

  1. Within "loc" folder you will see a file named "mystrings.d.ts". At first add property here like below:
declare interface ITestWebPartStrings {
  WebpartTitle: string;
}
  1. There is a file for english language named "en-us.js". If you want to add another language you have to create another file. For example if you want to add Norwegian language then you have to create "nb-NO.js" file.
  2. After that add the property in "nb-NO.js" file for Norwegian language. And for english language add property within "en-us.js" file as like below:
define([], function() {
    return {
        "WebpartTitle": "YourTitle",
    }
});
  1. Now you have to import in your file.
import * as strings from 'TestWebPartStrings';
  1. Now you can show "WebpartTitle" using "strings.WebpartTitle". This is the process to add multiple language.
let wpTitle = strings.WebpartTitle;

References:
1. nopvalley.com: Enabling Multilingual/Localization in SharePoint
2. From Microsoft documentation: Localize SharePoint Framework client-side web parts


If the answer is helpful, please upvote.

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.