HandyOrg / HandyOrg/HandyControl
Cannot change language (from chinese to English) with HandyControl window used within Excel VSTO Application
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 7.2k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
Issue Description:
When HandyControl and HandyControl.Lang.en package for developing Windows on an Excel VSTO Addin development, the language is always defaulting to Chinese, although it is explicitly set to use English.
Sub Issue 1: We cannot just create a new WPF window and set ConfigHelper.Instance.SetLang("en") since it will complain about not having an Application. To work around it, I create an Application window (HcTestApp) and call the WPF window (HcTest) from within it. (a pain, but a workaround, unless someone has a better way to handle this limitation in handycontrol)
Sub Issue 2: Even though this pseudo application sets the Resource dictionary, the sub-window needs to include it again under Window.Resources. This works for now.
What is tried so far:
- Have tried setting it in OnStartup() for HcTestApp.xaml as mentioned in this issue comment https://github.com/HandyOrg/HandyControl/issues/527#issuecomment-735360012
- Created a sample project to show the issue. The project was developed in VS 2022 with .Net framework 4.8.
- Have tried to set the "Lang" property directly. It assigns, but does not work.
- Have tried to ask the question in gitter a few times, but could not get a reply.
- Did not try HandyControls, since it is the master version as I understand.
Kindly let me know how we can solve this issue. Sub Issue 1 is a problem too, and I don't know if there is a workaround for that.
Steps to reproduce the bug
- Unzip the Project
- Build the solution and launch.
- Excel opens and you can see the add-in on the tab "ExcelAddinHCSimple"
- Click on the Button "Simple HC Control"
- The user list is a CheckCombobox, which has Select All in Chinese even though we set ConfigHelper.Instance.SetLang("en")
Please refer Screenshot below.
Expected behavior
"Select All" under the CheckComboBox should be shown in "English", but is shown in "Chinese"
Screenshots


NuGet package version
HandyControl 3.3.0
IDE
Visual Studio 2022
Framework type
.Net Framework 4.8
Windows version
May 2021 Update (19043)
Additional context
No response
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the attached ExcelAddInHCSimple.zip sample and inspect the HcTestApp/HcTest resource setup, ConfigHelper.Instance.SetLang("en"), and HandyControl.Lang.en usage. Reproduce the CheckComboBox in Excel and determine what must change so its "Select All" text is English without duplicating the resource dictionary in the sub-window.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100