localization-globalization
БесплатноБез исполняемых скриптовНе проверенMulti-language support, resource files, culture formatting, and globalization patterns for ASP.NET Core Razor Pages applications. Use when implementing…
от wshaddix★ 94 звезды на GitHubОб этом скилле
Rationale
Global applications require support for multiple languages, cultures, and formatting conventions. Poor localization implementation leads to maintenance nightmares, inconsistent user experiences, and hard-to-find bugs with dates, numbers, and currencies. These patterns provide a maintainable approach to building truly global Razor Pages applications.
Patterns
Pattern 1: Resource File Structure
Organize resources by feature with proper naming conventions and culture hierarchy.
/Pages
/Shared
_Layout.cshtml
Resources/
_Layout.resx (default/en)
_Layout.es.resx (Spanish)
_Layout.fr.resx (French)
_Layout.de.resx (German)
/Account
Login.cshtml
Login.cshtml.cs
Resources/
Login.resx
Login.es.resx
Login.fr.resx
/Products
Index.cshtml
Resources/
Index.resx
Index.es.resx
/Resources (Shared resources)
SharedResources.resx
SharedResources.es.resx
ValidationMessages.resx
// SharedResources.cs - Type-safe resource access
public class SharedResources
{
// This class is just a marker for IStringLocalizer<SharedResources>
}
// Strongly-typed resources with code generator
public static class ResourceKeys
{
public const string WelcomeMessage = "WelcomeMessage";
public const string SaveButton = "SaveButton";
public const string CancelButton = "CancelButton";
public const string ErrorOccurred = "ErrorOccurred";
public const string RequiredField = "RequiredField";
}
Pattern 2: Localization Configuration
Configure request localization with proper culture detection and fallback.
// Program.cs
var supportedCultures = new[]
{
new CultureInfo("en-US"),
new CultureInfo("en-GB"),
new CultureInfo("es-ES"),
new CultureInfo("es-MX"),
new CultureInfo("fr-FR"),
new CultureInfo("de-DE")
};
builder.Services.AddLocalization(options =>
{
options.ResourcesPath = "Resources";
});
builder.Services.AddRequestLocalization(options =>
{
options.DefaultRequestCulture = new RequestCulture("en-US");
options.SupportedCultures = supportedCultures;
options.SupportedUICultures = supportedCultures;
// Culture detection order:
// 1. Query string (?culture=es-ES)
// 2. Cookie (.AspNetCore.Culture)
// 3. Accept-Language header
// 4. Default culture
options.RequestCultureProviders = new List<IRequestCultureProvider>
{
new QueryStringRequestCultureProvider(),
new CookieRequestCultureProvider(),
new AcceptLanguageHeaderRequestCultureProvider()
};
});
// Register view localization
builder.Services.AddRazorPages()
.AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
.AddDataAnnotationsLocalization(options =>
{
options.DataAnnotationLocalizerProvider = (type, factory) =>
factory.Create(typeof(SharedResources));
});
// Middleware placement (must be before routing)
var app = builder.Build();
app.UseRequestLocalization();
app.UseRouting();
app.MapRazorPages();
Pattern 3: Razor Pages Localization
Implement view and PageModel localization with proper resource injection.
// PageModel with localization
public class ProductEditModel : PageModel
{
private readonly IStringLocalizer<ProductEditModel> _localizer;
private readonly IStringLocalizer<SharedResources> _sharedLocalizer;
private readonly ILogger<ProductEditModel> _logger;
public ProductEditModel(
IStringLocalizer<ProductEditModel> localizer,
IStringLocalizer<SharedResources> sharedLocalizer,
ILogger<ProductEditModel> logger)
{
_localizer = localizer;
_sharedLocalizer = sharedLocalizer;
_logger = logger;
}
[BindProperty]
public ProductInput Input { get; set; } = new();
public string PageTitle => _localizer["EditProductTitle"];
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid)
{
return Page();
}
try
{
await SaveProductAsync(Input);
TempData["SuccessMessage"] = _localizer["ProductSaved"];
return RedirectToPage("/Products/Index");
}
catch (Exception ex)
{
_logger.LogError(ex, "Failed to save product");
ModelState.AddModelError(string.Empty, _sharedLocalizer["ErrorOccurred"]);
return Page();
}
}
}
// View with localization
@page "{id:guid}"
@model ProductEditModel
@inject IStringLocalizer<SharedResources> SharedLocalizer
@inject IViewLocalizer ViewLocalizer
@{
ViewData["Title"] = Model.PageTitle;
}
<h1>@ViewLocalizer["EditProductTitle"]</h1>
<form method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="Input.Name">@ViewLocalizer["ProductName"]</label>
<input
Установить localization-globalization в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл localization-globalization?
Multi-language support, resource files, culture formatting, and globalization patterns for ASP.NET Core Razor Pages applications. Use when implementing multi-language support in ASP.NET Core applications, managing resource files for translations, or formatting dates, numbers, and currencies for different cultures.
Как установить скилл localization-globalization?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл localization-globalization запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic