Feature: add a language reset button and fit toolbar labels
The entry dialog showed the external language-pack folder with no way to disable it. Reset now clears the LangDir configuration value and restores a built-in language; it does not read, move or delete any file on disk. The current language is kept when already built-in (zh_CN/zh_TW/en_US); an external pack falls back to en_US. Startup treats a missing LangDir as ./lang and an explicitly empty one as built-ins only; scanner, loader, encoding check and the zh_CN patch skip disk access when the directory is empty. The button is created at runtime, sized from the localized label (German "Zuruecksetzen" fits) and matching OK/Cancel height; the folder field shrinks. Reset and the result message are translated in en_US, zh_TW and de_DE. Toolbar buttons share one width taken from the longest label. At the 1400-px startup window en_US used 76px per button and zh_TW 85px, clipping the last icons; zh_CN was 72px and de_DE 64px. Shortening the longest en_US/zh_TW labels brings both to 64px, so all 19 icons fit. Verified with a Debug x64 build: resetting a German pack leaves de_DE.ini on disk while settings become LangDir= and Language=en_US; a built-in zh_TW UI stays zh_TW; after restart with LangDir empty, only 3 built-ins are listed. English and zh_TW screenshots show all 19 toolbar buttons at startup. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
1d03cbeb3f
commit
3d2dd08be5
6 files changed
+226
-102
No files matched your search
@@ -3454,8 +3454,8 @@ void CMy2015RemoteDlg::InitFrpClients()
|
||||
PostMessageA(WM_SHOWMESSAGE, (WPARAM)msg, NULL);
|
||||
|
||||
auto langDir = THIS_CFG.GetStr("settings", "LangDir", "./lang");
|
||||
langDir = langDir.empty() ? "./lang" : langDir;
|
||||
if (!PathFileExists(langDir.c_str())) {
|
||||
// 缺省(键不存在)回退 ./lang;显式清空(LangDir=)表示不启用外部语言包,不再提示。
|
||||
if (!langDir.empty() && !PathFileExists(langDir.c_str())) {
|
||||
CharMsg* msg = new CharMsg(_TR("请通过\"扩展\"菜单指定语言包目录以支持多语言"));
|
||||
PostMessageA(WM_SHOWMESSAGE, (WPARAM)msg, NULL);
|
||||
}
|
||||
@@ -14757,7 +14757,23 @@ void CMy2015RemoteDlg::OnChangeLang()
|
||||
return;
|
||||
}
|
||||
|
||||
CString langCode = CLangSelectDlg::Show(this);
|
||||
bool reset = false;
|
||||
CString langCode = CLangSelectDlg::Show(this, &reset);
|
||||
if (reset) {
|
||||
// 只清空语言包目录变量;当前语言若是内置语言则保留,否则回退内置英文。
|
||||
CString targetLang = g_Lang.GetCurrentLanguage();
|
||||
if (targetLang.IsEmpty())
|
||||
targetLang = _T("zh_CN");
|
||||
if (targetLang != _T("zh_CN") && targetLang != _T("zh_TW") && targetLang != _T("en_US"))
|
||||
targetLang = _T("en_US");
|
||||
THIS_CFG.SetStr("settings", "LangDir", "");
|
||||
THIS_CFG.SetStr("settings", "Language", targetLang.GetString());
|
||||
g_Lang.ClearLangDir();
|
||||
g_Lang.Load(targetLang);
|
||||
MessageBoxL(_TR("已清空语言包目录设置,已恢复内置语言,重启程序后生效。"),
|
||||
_TR("提示"), MB_ICONINFORMATION);
|
||||
return;
|
||||
}
|
||||
if (!langCode.IsEmpty()) {
|
||||
if (!g_Lang.CheckEncoding(langCode)) {
|
||||
MessageBoxL("请使用ANSI编码的语言文件。", "提示", MB_ICONWARNING);
|
||||
@@ -14776,7 +14792,10 @@ void CMy2015RemoteDlg::OnChangeLang()
|
||||
|
||||
void CMy2015RemoteDlg::OnChooseLangDir()
|
||||
{
|
||||
CFolderPickerDialog folderDlg(THIS_CFG.GetStr("settings", "LangDir", "./lang").c_str(), NULL, this, 0);
|
||||
std::string startDir = THIS_CFG.GetStr("settings", "LangDir", "./lang");
|
||||
if (startDir.empty())
|
||||
startDir = "./lang"; // 已清空时从默认目录开始选
|
||||
CFolderPickerDialog folderDlg(startDir.c_str(), NULL, this, 0);
|
||||
CString strTitle = _TR("请选择目录");
|
||||
folderDlg.m_ofn.lpstrTitle = strTitle;
|
||||
if (folderDlg.DoModal() == IDOK) {
|
||||
|
||||
Reference in new issue
Block a user