Available in
Marketplaces, most starred first
Tags
Add to README
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Claude loads one when your task matches it, or you run it by name.
1 marketplace, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
A Roslyn incremental source generator that creates strongly typed classes from your .resx files for use with IStringLocalizer from Microsoft.Extensions.Localization.
📖 Documentation: shinylib.net/localizegen
This is very much adapted (and a bunch copied) code from https://github.com/VocaDB/ResXFileCodeGenerator
Hello {0}), including format specifiers like {0:C2} or {1:yyyy-MM-dd}.resx comment field (falls back to the resource value)RootNamespace and folder structureAddStronglyTypedLocalizations() extension to register everything with dependency injectioninternal accessor for generated classespartial so you can extend themThis directory structure:
Will generate:
Only the default (culture neutral) .resx files generate classes - culture specific files such as MyViewModel.fr-ca.resx are picked up at runtime by IStringLocalizer.
dotnet add package Microsoft.Extensions.Localization
dotnet add package Shiny.Extensions.Localization.Generator
MauiProgram.cs, Program.cs, or wherever you configure servicesbuilder.Services.AddStronglyTypedLocalizations(); // also calls AddLocalization() for you
.resx file to your project that matches the name of a class (ie. ViewModel, Controller, Service, etc).public class MyViewModel
{
public MyViewModel(MyViewModelLocalized localizer) // same namespace and class name with "Localized" suffix
=> this.Localizer = localizer;
public MyViewModelLocalized Localizer { get; }
}
<Label Text="{Binding Localizer.MyKey}" />
[!WARNING] If the "class" beside the resource does not exist, a compile error will occur with the generated code
Any resource value containing indexed placeholders generates a method instead of a property. The method name gets a Format suffix (unless the key already ends with Format), and placeholders with format specifiers are fully supported.
<data name="Greeting" xml:space="preserve">
<value>Hello {0}, you have {1} new messages</value>
</data>
<data name="TotalCost" xml:space="preserve">
<value>Total cost: {0:C2}</value>
</data>
<data name="WelcomeMessage" xml:space="preserve">
<value>Welcome!</value>
</data>
Generates:
public string GreetingFormat(object parameter0, object parameter1)
=> string.Format(this.localizer["Greeting"], parameter0, parameter1);
public string TotalCostFormat(object parameter0)
=> string.Format(this.localizer["TotalCost"], parameter0);
public string WelcomeMessage => this.localizer["WelcomeMessage"];
Notes:
Start: {0:HH:mm}, End: {0:HH:mm:ss}) produces a single parameter{name}, {}) are left alone and still produce a propertyAdd a comment to a resource in the .resx file and it becomes the <summary> of the generated member, so you get intellisense describing what the string is for. If there is no comment, the resource value is used instead.
<data name="WelcomeMessage" xml:space="preserve">
<value>Welcome to our app!</value>
<comment>Displayed on the home screen when user first opens the app</comment>
</data>
/// <summary>
/// Displayed on the home screen when user first opens the app
/// </summary>
public string WelcomeMessage => this.localizer["WelcomeMessage"];
Built from public signals: copy clicks on this site, GitHub stars and activity, the README and the manifest. Not a security audit or an endorsement.
Plugins from other owners that cover similar ground
npx claudepluginhub shinyorg/localizegen --plugin localizegen