Localization
Elsa Studio Localization
Elsa Studio Localization allows localizing the Studio UI to different languages.
ILocalizationProvider
is the interface that needs to be implemented to provide the localized strings for the Studio UI.
Create your own localization file (Using the resource file or any alternative method' and implement the ILocalizationProvider
interface.
Afterwards, register your implementation in the DI container.
builder.Services.AddSingleton<ILocalizationProvider, MyLocalizationProvider>();
Steps to Enable Localization
For Blazor Server
Add Reference to
Elsa.Studio.Localization.BlazorServer
package.Add the following to your
Program.cs
// Define the Localization Configuration var localizationConfig = new LocalizationConfig { ConfigureLocalizationOptions = options => { configuration.GetSection(LocalizationOptions.LocalizationSection).Bind(options); options.SupportedCultures = new[] { options?.DefaultCulture ?? new LocalizationOptions().DefaultCulture } .Concat(options?.SupportedCultures.Where(culture => culture != options?.DefaultCulture) ?? []) .ToArray(); } }; // Register the Localization Module builder.Services.AddLocalizationModule(localizationConfig); // If using your own, register your locallization provider builder.Services.AddSingleton<ILocalizationProvider, MyLocalizationProvider>(); // Add The localization Middleware. Making Sure that Controllers are also mapped. app.UseElsaLocalization(); app.MapControllers();
Add below configuration in the
appsettings.json
file, specifying the supported cultures."Localization": { "DefaultCulture": "en-US", "SupportedCultures": [ "en-GB", "nl-NL" ] }
For Blazor WebAssembly
Add Reference to
Elsa.Studio.Localization.BlazorWasm
package.Define the Localization Configuration
// Define the Localization Configuration var localizationConfig = new LocalizationConfig { ConfigureLocalizationOptions = options => { configuration.GetSection(LocalizationOptions.LocalizationSection).Bind(options); options.SupportedCultures = new[] { options?.DefaultCulture ?? new LocalizationOptions().DefaultCulture } .Concat(options?.SupportedCultures.Where(culture => culture != options?.DefaultCulture) ?? []) .ToArray(); } }; // Register the Localization Module builder.Services.AddLocalizationModule(localizationConfig); // If using your own, register your locallization provider builder.Services.AddSingleton<ILocalizationProvider, MyLocalizationProvider>(); // Use the localization Middleware await app.UseElsaLocalization();
Add below configuration in the
appsettings.json
file, specifying the supported cultures."Localization": { "DefaultCulture": "en-US", "SupportedCultures": [ "en-GB", "nl-NL" ] }
Last updated