一键导入
localizegen
Generate strongly-typed localization classes from .resx resource files using Shiny.Extensions.Localization.Generator for .NET applications
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Generate strongly-typed localization classes from .resx resource files using Shiny.Extensions.Localization.Generator for .NET applications
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Guide for implementing Firebase Cloud Messaging push notifications in .NET MAUI apps using Shiny.Push.FirebaseMessaging on iOS and Android.
Generate code using Shiny.DocumentDb.Firestore.Mobile, an on-device (native) Firebase Firestore provider for Shiny.DocumentDb on iOS and Android — offline-first persistence, real-time snapshot listeners, LINQ queries, and managed Firebase Auth identity.
Generate code using Shiny.Extensions.Push, a server-side push notification dispatch library for .NET with a provider-agnostic core and transports for APNs (.p8/ES256), FCM (HTTP v1), Web Push (VAPID + RFC 8291) and WNS (Windows App SDK / Entra auth), plus Shiny.DocumentDb persistence, structured targeting, topics, interceptors, dead-token pruning, multi-app keyed registration, runtime static/dynamic (multi-tenant) configuration via IPushConfigurationProvider, and System.Diagnostics.Metrics + tracing — fully AOT/trim-safe.
Generate code using Shiny.Speech for cross-platform speech-to-text, text-to-speech, audio capture, and audio playback with pluggable cloud providers
Shiny BluetoothLE client/central operations for scanning, connecting, and communicating with BLE peripherals
Generate code for Shiny.AiConversation - a centralized AI service library for .NET MAUI apps with chat client abstraction, wake word detection, speech-to-text/text-to-speech, acknowledgement modes (None/AudioBlip/LessWordy/Full), persistent message store, optional AI chat history lookup tool, and configurable sound effects
| name | localizegen |
| description | Generate strongly-typed localization classes from .resx resource files using Shiny.Extensions.Localization.Generator for .NET applications |
| auto_invoke | true |
| triggers | ["localization","localize","resx","resource file","IStringLocalizer","StringLocalizer","strongly typed localization","AddStronglyTypedLocalizations","Localized class","localizegen","Shiny.Extensions.Localization.Generator","i18n","internationalization","translate","translation"] |
You are an expert in Shiny.Extensions.Localization.Generator, a Roslyn incremental source generator that creates strongly-typed localization classes from .resx resource files for use with Microsoft.Extensions.Localization.
Invoke this skill when the user wants to:
.resx filesMicrosoft.Extensions.Localization with generated code.resx resource files with matching classesNuGet: Shiny.Extensions.Localization.Generator
Namespace: Generated classes use the namespace derived from the project's RootNamespace and folder structure
Target: .NET Standard 2.0 (works with any modern .NET application)
Shiny.Extensions.Localization.Generator is a Roslyn incremental source generator that:
.resx files at compile time and generates strongly-typed C# classes"Hello {0}")ServiceCollectionExtensions class with AddStronglyTypedLocalizations() for DI registration.resx comment fieldsdotnet add package Microsoft.Extensions.Localization
dotnet add package Shiny.Extensions.Localization.Generator
builder.Services.AddLocalization();
builder.Services.AddStronglyTypedLocalizations();
.resx file must have a corresponding C# class with the same name in the same namespace (e.g., MyViewModel.resx requires MyViewModel.cs).resx file is processed (e.g., MyViewModel.resx), locale-specific files like MyViewModel.fr-ca.resx are handled by the localization framework at runtime{ClassName}Localized class (e.g., MyViewModelLocalized) for each .resx fileMyApp/
├── MyViewModel.cs
├── MyViewModel.resx # Default locale (English)
├── MyViewModel.fr-ca.resx # French-Canadian locale
├── Folder1/
│ ├── FolderViewModel.cs
│ ├── FolderViewModel.resx
│ └── FolderViewModel.fr-ca.resx
MyApp/
├── MyViewModelLocalized.g.cs # RootNamespace.MyViewModelLocalized
├── Folder1.FolderViewModelLocalized.g.cs # RootNamespace.Folder1.FolderViewModelLocalized
├── ServiceCollectionExtensions.g.cs # DI registration extension method
.), hyphens (-), and spaces in resource keys are converted to underscores (_){0}, {1} are detected automaticallyFormat suffix unless the key already ends with FormatWhen working with this library:
Create .resx files alongside their associated C# class:
<?xml version="1.0" encoding="utf-8"?>
<root>
<data name="Welcome" xml:space="preserve">
<value>Welcome to our app!</value>
<comment>Greeting shown on the home page</comment>
</data>
<data name="UserGreeting" xml:space="preserve">
<value>Hello {0}, welcome to {1}!</value>
<comment>Personalized greeting with user name and app name</comment>
</data>
<data name="ItemCount" xml:space="preserve">
<value>You have {0} items in your cart</value>
</data>
</root>
The class must exist with the same name and namespace as the .resx file:
namespace MyApp;
public class MyViewModel
{
public MyViewModel(MyViewModelLocalized localizer)
{
this.Localizer = localizer;
}
public MyViewModelLocalized Localizer { get; }
}
The generator creates:
namespace MyApp;
public partial class MyViewModelLocalized
{
readonly IStringLocalizer localizer;
public MyViewModelLocalized(IStringLocalizer<MyViewModel> localizer)
{
this.localizer = localizer;
}
public IStringLocalizer Localizer => this.localizer;
/// <summary>
/// Greeting shown on the home page
/// </summary>
public string Welcome => this.localizer["Welcome"];
/// <summary>
/// Personalized greeting with user name and app name
/// </summary>
public string UserGreetingFormat(object parameter0, object parameter1)
{
return string.Format(this.localizer["UserGreeting"], parameter0, parameter1);
}
/// <summary>
/// You have {0} items in your cart
/// </summary>
public string ItemCountFormat(object parameter0)
{
return string.Format(this.localizer["ItemCount"], parameter0);
}
}
Bind in XAML with full IntelliSense:
<Label Text="{Binding Localizer.Welcome}" />
Place files following standard .NET conventions:
MyClass.fr-ca.resx)Folder1/MyClass.resx → RootNamespace.Folder1To generate classes with internal instead of public access modifier:
<PropertyGroup>
<GenerateLocalizersInternal>True</GenerateLocalizersInternal>
</PropertyGroup>
Simple property access:
var localizer = services.GetRequiredService<MyViewModelLocalized>();
Console.WriteLine(localizer.Welcome);
Format string method:
Console.WriteLine(localizer.UserGreetingFormat("Allan", "MyApp"));
// Output: Hello Allan, welcome to MyApp!
XAML binding in MAUI:
<Label Text="{Binding Localizer.Welcome}" />
ASP.NET/Blazor usage:
@inject MyViewModelLocalized Localizer
<h1>@Localizer.Welcome</h1>
<p>@Localizer.UserGreetingFormat(User.Name, "MyApp")</p>
.resx file must have a matching C# class or a compile error will occur{0}, {1} etc. generate type-safe methodsClassName.resx is processed; ClassName.fr-ca.resx is for runtime localization{ClassName}Localized, not IStringLocalizer directlyLocalizer property for edge cases needing IStringLocalizer.resx files in folders to match your namespace conventionsFor detailed templates and examples, see:
reference/templates.md - Code generation templates for common patternsreference/api-reference.md - Full API surface, MSBuild properties, and troubleshootingdotnet add package Shiny.Extensions.Localization.Generator # Source generator
dotnet add package Microsoft.Extensions.Localization # Localization framework
dotnet add package Microsoft.Extensions.DependencyInjection # DI container