maui-localization

.NET MAUI 应用的本地化指导,围绕使用 .resx 资源实现多语言支持、文化区域解析与运行时切换、从右到左(RTL)布局、平台语言声明(如 iOS/Mac Catalyst 的 Info.plist、Windows 的 Package.appxmanifest)以及图像本地化策略。

仓库最近推送
GitHub Stars
181
Forks
21
Issues / PRs
1

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "maui-localization":https://skillpi.com/zh/skills/deepskill-52b29f212c2ef9d194ffd73681f1fc59eacc07f4c2216987c0b44f9d55dde05b。安装前核对上游来源和版本:https://github.com/davidortinau/maui-skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

.NET MAUI 应用的本地化指导,围绕使用 .resx 资源实现多语言支持、文化区域解析与运行时切换、从右到左(RTL)布局、平台语言声明(如 iOS/Mac Catalyst 的 Info.plist、Windows 的 Package.appxmanifest)以及图像本地化策略。

0 下载

介绍来源: third_party · davidortinau · 0.0.1 参考来源

SkillPi 解读

实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: maui-localization
description: >-
  Guidance for localizing .NET MAUI apps: multi-language support via .resx resource files,
  culture resolution and runtime switching, RTL layout, platform language declarations
  (iOS/Mac Catalyst Info.plist, Windows Package.appxmanifest), and image localization strategies.
  USE FOR: "localization", "multi-language", "resx resource", "translate app", "RTL layout",
  "culture switching", "localize strings", "right-to-left", "language support MAUI",
  "Info.plist languages".
  DO NOT USE FOR: theming or visual styles (use maui-theming), accessibility labels
  (use maui-accessibility), or content from REST APIs (use maui-rest-api).

.NET MAUI Localization

Common gotchas

Issue Fix
ResourceManager returns null for default culture Set <NeutralLanguage>en-US</NeutralLanguage> in .csproj
iOS ignores culture overrides CFBundleLocalizations missing from Info.plist
Windows doesn't show correct language <Resource Language="..." /> missing from Package.appxmanifest
x:Static bindings don't update on language switch x:Static is one-time — use binding approach with INotifyPropertyChanged
.Designer.cs not regenerating in VS Code Add <CoreCompileDependsOn>PrepareResources;$(CoreCompileDependsOn)</CoreCompileDependsOn> and run dotnet build

⚠️ NeutralLanguage is mandatory

<!-- ✅ Always set in .csproj -->
<PropertyGroup>
  <NeutralLanguage>en-US</NeutralLanguage>
</PropertyGroup>

<!-- ❌ Missing this causes ResourceManager to return null at runtime -->

Platform declarations — don't forget these

iOS / Mac Catalyst

⚠️ Without this, iOS won't offer your app's languages in system Settings:

<!-- Platforms/iOS/Info.plist AND Platforms/MacCatalyst/Info.plist -->
<key>CFBundleLocalizations</key>
<array>
  <string>en</string>
  <string>es</string>
  <string>fr</string>
</array>

Windows

<!-- Platforms/Windows/Package.appxmanifest -->
<Resources>
  <Resource Language="en-US" />
  <Resource Language="es" />
  <Resource Language="fr-FR" />
</Resources>

Android

Android picks up .resx-based localization automatically. No additional manifest entries required. ✅

Runtime language switching — x:Static trap

<!-- ❌ Won't update when language changes at runtime -->
<Label Text="{x:Static resx:AppResources.WelcomeMessage}" />

<!-- ✅ Updates dynamically via INotifyPropertyChanged -->
<Label Text="{Binding [WelcomeMessage], Source={x:Static local:LocalizationResourceManager.Instance}}" />

When switching culture, set all three properties or formatting is inconsistent:

// ✅ Complete culture switch
var culture = new CultureInfo("es");
CultureInfo.CurrentUICulture = culture;  // resource lookup
CultureInfo.CurrentCulture = culture;     // dates/numbers
AppResources.Culture = culture;           // ResourceManager

// ❌ Only sets UI culture — dates/numbers stay in old culture
CultureInfo.CurrentUICulture = new CultureInfo("es");

RTL layout — set FlowDirection at page level

<!-- ✅ Page-level — children inherit -->
<ContentPage FlowDirection="RightToLeft">
  <StackLayout FlowDirection="MatchParent" />
</ContentPage>

<!-- ❌ Only on child — parent still LTR, layout breaks -->
<ContentPage>
  <StackLayout FlowDirection="RightToLeft" />
</ContentPage>

VS Code pitfall

⚠️ .Designer.cs may not regenerate on save. Add to .csproj and run dotnet build after .resx changes:

<CoreCompileDependsOn>PrepareResources;$(CoreCompileDependsOn)</CoreCompileDependsOn>

Decision framework

Need Approach
Static multilingual strings .resx files with x:Static bindings
Runtime language switching LocalizationResourceManager with INotifyPropertyChanged bindings
Culture-specific images Name images banner_{culture}.png or store paths in .resx
RTL support Set FlowDirection at page level, detect with TextInfo.IsRightToLeft
Date/number formatting Set CultureInfo.CurrentCulture alongside CurrentUICulture

Quick checklist

  • [ ] NeutralLanguage set in .csproj
  • [ ] Default AppResources.resx contains all keys
  • [ ] Each target language has its own AppResources.{culture}.resx
  • [ ] iOS/Mac: CFBundleLocalizations lists all supported languages
  • [ ] Windows: Package.appxmanifest declares <Resource Language="..." />
  • [ ] RTL cultures set FlowDirection at page/app level
  • [ ] Runtime switching sets all three: CurrentUICulture, CurrentCulture, AppResources.Culture
  • [ ] dotnet build regenerates .Designer.cs after .resx changes

当前收录版本

0.0.1

核对来源版本 ↗

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值90/100

亮点

  • 提供 .NET MAUI 应用本地化的完整指南,涵盖多语言支持、文化区域解析、运行时切换、RTL 布局、平台语言声明和图像本地化策略
  • 内容实用性强,针对开发者常见痛点提供具体解决方案和最佳实践
触发精准90/100

亮点

  • 触发词精准完整,覆盖多种变体,边界清晰
  • 明确区分适用与不适用场景,避免误用
结构规范90/100

亮点

  • 结构清晰,包含常见问题、平台声明、运行时切换、RTL 布局、VS Code 陷阱、决策框架和快速检查清单
  • 提供端到端示例和具体代码片段,便于理解和实施
执行可靠90/100

亮点

  • 工具来源明确,参数正确,覆盖主要异常
  • 提供完整的文化切换示例和平台特定配置,确保执行可靠性
证据可验 (前四项均值)90/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。