Skip to content

Usage Examples

var localizer = services.GetRequiredService<MyViewModelLocalized>();
// Simple string property
Console.WriteLine(localizer.Welcome);
// Format string method
Console.WriteLine(localizer.UserGreetingFormat("Allan", "MyApp"));
// Output: Hello Allan, welcome to MyApp!
<Label Text="{Binding Localizer.Welcome}" />
@inject MyViewModelLocalized Localizer
<h1>@Localizer.Welcome</h1>
<p>@Localizer.UserGreetingFormat(User.Name, "MyApp")</p>

The generated class exposes the underlying IStringLocalizer for edge cases:

// Dynamic key lookup when you need it
var value = localizer.Localizer["SomeDynamicKey"];

Generate classes with internal instead of public access:

<PropertyGroup>
<GenerateLocalizersInternal>True</GenerateLocalizersInternal>
</PropertyGroup>

An AI skill is available for the Localization Generator to help generate localized classes, configure .resx files, and follow best practices directly in your IDE.

Claude Code

Terminal window
claude plugin add github:shinyorg/skills

GitHub Copilot — Copy the localizegen skill file into your repository’s custom instructions.