Add multi-language support (zh-CN / en / ja) to RevitGenTest#3
Add multi-language support (zh-CN / en / ja) to RevitGenTest#3
Conversation
Co-authored-by: ShrlAlgo <40654941+ShrlAlgo@users.noreply.github.com> Agent-Logs-Url: https://github.com/ShrlAlgo/RevitGen/sessions/312799f0-4efa-4380-8607-b68f27ac5497
There was a problem hiding this comment.
Pull request overview
This PR introduces basic localization plumbing for the RevitGenTest add-in by moving user-facing strings into .resx resources and adding culture-specific resource files (en/ja), alongside a small helper to persist and apply a chosen UI language.
Changes:
- Added localized string entries to
Properties/Resources.resx(default/Chinese) and introducedResources.en.resxandResources.ja.resx. - Updated
RevitAddin.csto useProperties.Resourcesfor runtime UI strings. - Added
LanguageManagerto load/save a language preference and apply aCurrentUICulture/resource culture override.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| RevitGenTest/RevitGenTest.csproj | Adds culture-specific .resx files to the project for satellite resource builds. |
| RevitGenTest/RevitAddin.cs | Replaces hardcoded UI strings with resource lookups. |
| RevitGenTest/Properties/Resources.resx | Adds new string keys for wall-related messages. |
| RevitGenTest/Properties/Resources.en.resx | Adds English translations for the new string keys. |
| RevitGenTest/Properties/Resources.ja.resx | Adds Japanese translations for the new string keys. |
| RevitGenTest/Properties/Resources.Designer.cs | Adds strongly-typed accessors for the new string keys. |
| RevitGenTest/LanguageManager.cs | Introduces persistence + application of UI language preference. |
Files not reviewed (1)
- RevitGenTest/Properties/Resources.Designer.cs: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <EmbeddedResource Include="Properties\Resources.en.resx"> | ||
| <ManifestResourceName>RevitGenTest.Properties.Resources</ManifestResourceName> | ||
| <Culture>en</Culture> | ||
| </EmbeddedResource> | ||
| <EmbeddedResource Include="Properties\Resources.ja.resx"> |
There was a problem hiding this comment.
In SDK-style .csproj projects, .resx files are already included as EmbeddedResource by default. Adding them again with Include can trigger MSBuild “Duplicate EmbeddedResource items” errors. Prefer using EmbeddedResource Update="Properties\Resources.en.resx" / Update="Properties\Resources.ja.resx" to attach Culture/ManifestResourceName metadata without duplicating the items (similar to how Resources.resx is handled above).
| <EmbeddedResource Include="Properties\Resources.en.resx"> | |
| <ManifestResourceName>RevitGenTest.Properties.Resources</ManifestResourceName> | |
| <Culture>en</Culture> | |
| </EmbeddedResource> | |
| <EmbeddedResource Include="Properties\Resources.ja.resx"> | |
| <EmbeddedResource Update="Properties\Resources.en.resx"> | |
| <ManifestResourceName>RevitGenTest.Properties.Resources</ManifestResourceName> | |
| <Culture>en</Culture> | |
| </EmbeddedResource> | |
| <EmbeddedResource Update="Properties\Resources.ja.resx"> |
Hardcoded Chinese runtime strings in
RevitAddin.csare replaced with a proper .NET localization stack supporting Chinese (default), English, and Japanese.Resource files
NoWallsFound,SuccessTitle,FoundWallsMessagestring entries toResources.resx(zh-CN fallback)Resources.en.resxandResources.ja.resxwith equivalent translationsEmbeddedResourcewithCulturemetadata in the.csprojso MSBuild emits proper satellite assembliesDesigner
Resources.Designer.cswith strongly-typed accessors for the three new string keysLanguageManager
New
LanguageManager.csstatic class:SupportedLanguages—{ "zh-CN", "en", "ja" }LoadLanguagePreference()/SaveLanguagePreference(string)— persists chosen locale to%APPDATA%\RevitGenTest\language.txtSwitchLanguage(string)— setsThread.CurrentThread.CurrentUICultureandProperties.Resources.Culture, then savesUsage after the change
Original prompt
This pull request was created from Copilot chat.
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.