From 8558413067368accdb834425711eba2934c843a6 Mon Sep 17 00:00:00 2001 From: Qiu Hao Date: Sun, 26 Oct 2025 17:42:22 +0800 Subject: [PATCH 1/2] feat: Add full internationalization support with Chinese and English - Implement i18n with automatic VS language detection - Add 190+ localized strings for Settings and Search UI - Use VsShellUtilities.ShowMessageBox for proper button localization - Add SecondaryButton style for lower-priority UI actions - Support future language extensibility --- README.md | 4 + .../CodeIndex.VisualStudioExtension.csproj | 16 + .../Controls/CodeIndexSearchControl.xaml | 42 +- .../Controls/CodeIndexSearchControl.xaml.cs | 15 +- .../Controls/SettingsWindow.xaml | 153 +++- .../Converts/LocalizationHelper.cs | 12 + .../Converts/LocalizeConverter.cs | 35 + .../Models/CodeIndexSearchViewModel.cs | 62 +- .../Models/SettingsViewModel.cs | 43 +- .../ExtensionResourceDictionary.xaml | 29 +- .../Resources/Strings.Designer.cs | 711 ++++++++++++++++++ .../Resources/Strings.resx | 301 ++++++++ .../Resources/Strings.zh-CN.resx | 301 ++++++++ .../Services/LocalizationService.cs | 77 ++ .../source.extension.vsixmanifest | 2 +- 15 files changed, 1714 insertions(+), 89 deletions(-) create mode 100644 src/CodeIndex.VisualStudioExtension/Converts/LocalizationHelper.cs create mode 100644 src/CodeIndex.VisualStudioExtension/Converts/LocalizeConverter.cs create mode 100644 src/CodeIndex.VisualStudioExtension/Resources/Strings.Designer.cs create mode 100644 src/CodeIndex.VisualStudioExtension/Resources/Strings.resx create mode 100644 src/CodeIndex.VisualStudioExtension/Resources/Strings.zh-CN.resx create mode 100644 src/CodeIndex.VisualStudioExtension/Services/LocalizationService.cs diff --git a/README.md b/README.md index 0a34dfa..eb364b6 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,10 @@ Latest improvements to the Visual Studio extension - Replaced WinForms dialog with Vista IFileOpenDialog (better UX); removed System.Windows.Forms dependency. - Theme-Aware UI - Buttons/styles now use Visual Studio dynamic theme brushes (light/dark/HC) instead of hardcoded colors. +- Internationalization (i18n) + - Full multi-language support with automatic VS language detection. + - Currently supports English and Simplified Chinese (易于扩展其他语言). + - All UI elements (windows, buttons, messages) fully localized. - Quick Navigation Buttons - Open buttons beside Local & Remote URLs (auto prepend http:// when missing). - Responsive Async Commands diff --git a/src/CodeIndex.VisualStudioExtension/CodeIndex.VisualStudioExtension.csproj b/src/CodeIndex.VisualStudioExtension/CodeIndex.VisualStudioExtension.csproj index c001715..ff557e7 100644 --- a/src/CodeIndex.VisualStudioExtension/CodeIndex.VisualStudioExtension.csproj +++ b/src/CodeIndex.VisualStudioExtension/CodeIndex.VisualStudioExtension.csproj @@ -60,6 +60,15 @@ Models\CodeContentProcessing.cs + + + PublicResXFileCodeGenerator + Strings.Designer.cs + + + Strings.resx + + Resources\Extension-Icon.png @@ -128,6 +137,13 @@ + + + True + True + Strings.resx + + $(NoWarn);MSB4011 diff --git a/src/CodeIndex.VisualStudioExtension/Controls/CodeIndexSearchControl.xaml b/src/CodeIndex.VisualStudioExtension/Controls/CodeIndexSearchControl.xaml index 7645863..0022250 100644 --- a/src/CodeIndex.VisualStudioExtension/Controls/CodeIndexSearchControl.xaml +++ b/src/CodeIndex.VisualStudioExtension/Controls/CodeIndexSearchControl.xaml @@ -4,6 +4,8 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:vsshell="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.15.0" + xmlns:cvt="clr-namespace:CodeIndex.VisualStudioExtension.Converts" + xmlns:res="clr-namespace:CodeIndex.VisualStudioExtension.Resources" mc:Ignorable="d" d:DesignHeight="281.2" d:DesignWidth="987.2" Foreground="{DynamicResource {x:Static vsshell:VsBrushes.WindowTextKey}}" @@ -13,37 +15,37 @@ - + - - - + + - - - - -