Loading...

How to make a SharePoint Web Part multilingual

How to make a SharePoint Web Part multilingual

If you want to easily allow users to have your SPFx Web Part in a language of their liking, this guide is for you. To enable this multi language feature, we need

  1. Define the keys and their types for localized strings in the mystrings.d.ts file like this:
declare interface ISvgToJsonWebPartStrings {
 saveConfiguration: string;
 libraryName: string;
 column: string;
 selectColumn: string;
}

declare module 'SvgToJsonWebPartStrings' {
 const strings: ISvgToJsonWebPartStrings;
 export = strings;
}

Depending on how much text you have in your Web Part, this can be a rather tedious task 😇.

(replace the SvgToJsonWebPartStrings with your Web Part Name)

  1. Now in the en-us.js file (it’s in the loc folder) you will define for each of your keys that you have in the mystrings.d.ts file, a key-value pair in english. If you also need de-de.js for german, or fr-fr.js for french or any other language, create a file with the name of that locale in the loc folder and provide a translated version of the values of the en-us.js file (Hello 👋 Copilot).

This should look a bit like this:

define([], function() {
 return {
 "saveConfiguration": "Konfiguration speichern",
 "LibraryName": "Bibliotheksname",
 "column": "Spalte",
 "selectColumn": "Wählen Sie eine Spalte"
 }
});
  1. Now replace all the hard coded strings like button texts, placeholders, labels, error messages etc. with strings.<keyname>, so for example strings.column.
  2. As a last step, you need to import the strings into the file you want to use them with something like import * as strings from 'SvgToJsonWebPartStrings';

If you now run gulp build and gulp serve again to try out your masterpiece in te workbench and want to see your newly added languages, append the URL https://<your tenant>.sharepoint.com/_layouts/15/workbench.aspx with ?locale=de-de or any other locale that you created.

web part in workbench with enable de-de locale

Congrats! You enabled a multi-language feature in your Web Part and also improved the logic of it. Now if you change a text, that will appear two or more times in your Web Part once it reflects this everywhere, so less manual changes!

If you want to have a look at the Web Part (which is still work in progress), you can do this here: react-svg-to-json-converter/. Let me know what you think!

Published on:

Learn more
Luise Freese: Consultant & MVP
Luise Freese: Consultant & MVP

Recent content on Luise Freese: Consultant & MVP

Share post:

Related posts

Microsoft 365 Copilot Licensing Simplified

Changes have been announced that simplify the licensing of Microsoft 365 Copilot, but also broaden the scope of the product and make it better...

16 hours ago

Microsoft Teams: Improvements in call transfer experience on Teams Phone devices

Microsoft Teams Phone devices will have improved call transfer experience by mid-October 2025, enhancing speed, reliability, and UI clarity fo...

18 hours ago

Microsoft 365 Copilot Apps installation on devices with Microsoft 365 Apps

Starting October 2025, Microsoft will automatically install the Microsoft 365 Copilot app on Windows devices with Microsoft 365 desktop apps, ...

18 hours ago

Expanding Microsoft 365 Copilot Search admin experience to AI admin role

Microsoft 365 is introducing an AI Admin Role for Copilot Search, enabling designated admins to manage AI-powered search across tenants. Rolli...

18 hours ago

(Teams Premium) Customize the screen in Teams Town hall through “Manage what attendees see”

Teams Premium will introduce “Manage what attendees see” for town halls, allowing organizers to customize layouts, backgrounds, th...

18 hours ago

Microsoft Defender for Office 365: Enhanced email entity page experience

Microsoft Defender for Office 365 will streamline the email entity page by opening emails in a shared tab with retained navigation and unique ...

18 hours ago

New filtering capability for SharePoint Embedded containers using sensitivity labels

SharePoint Embedded will introduce a new default filtering feature by sensitivity labels for containers, rolling out worldwide from late Octob...

18 hours ago

Membership management of SharePoint Embedded containers through PowerShell

New PowerShell cmdlets for managing SharePoint Embedded container membership will roll out worldwide from late September to October 2025. Admi...

18 hours ago

Update Principal owner of a SharePoint Embedded user-owned container through SPAC and PowerShell

SharePoint Embedded will allow admins to update the principal owner of user-owned containers via the SharePoint Admin Center or PowerShell sta...

18 hours ago

Microsoft Copilot (Microsoft 365): [Copilot Extensibility] Improve discovery of Champion connector prompts for Users

Improve discovery of Champion connector prompts – inline suggestive pre & post prompts, prompt library. Product Release phase Gener...

18 hours ago
Stay up to date with latest Microsoft Dynamics 365 and Power Platform news!
* Yes, I agree to the privacy policy