1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
// LangPage.cpp
#include "StdAfx.h"
#include "resource.h"
#include "LangPage.h"
#include "Common/StringConvert.h"
#include "Windows/Defs.h"
#include "Windows/FileFind.h"
#include "../../RegistryUtils.h"
#include "../../HelpUtils.h"
#include "../../LangUtils.h"
#include "../../ProgramLocation.h"
#include "../../MyLoadMenu.h"
static CIDLangPair kIDLangPairs[] =
{
{ IDC_LANG_STATIC_LANG, 0x01000401}
};
static LPCWSTR kLangTopic = L"FM/options.htm#language";
bool CLangPage::OnInit()
{
_langWasChanged = false;
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
_langCombo.Attach(GetItem(IDC_LANG_COMBO_LANG));
int index = _langCombo.AddString(TEXT("English (English)"));
_langCombo.SetItemData(index, _paths.Size());
_paths.Add(TEXT(""));
_langCombo.SetCurSel(0);
UString folderPath;
if (::GetProgramFolderPath(folderPath))
{
folderPath += L"Lang\\";
NWindows::NFile::NFind::CEnumeratorW enumerator(folderPath + L"*.txt");
NWindows::NFile::NFind::CFileInfoW fileInfo;
while (enumerator.Next(fileInfo))
{
if (fileInfo.IsDirectory())
continue;
CLang lang;
UString filePath = folderPath + fileInfo.Name;
UString shortName;
const kExtSize = 4;
if (fileInfo.Name.Right(kExtSize) != L".txt")
continue;
shortName = fileInfo.Name.Left(fileInfo.Name.Length() - kExtSize);
if (lang.Open(GetSystemString(filePath)))
{
UString name;
UString englishName, nationalName;
if (lang.GetMessage(0x00000000, englishName))
name = englishName;
else
name = shortName;
if (lang.GetMessage(0x00000001, nationalName))
{
if (!nationalName.IsEmpty())
{
name += L" (";
name += nationalName;
name += L")";
}
}
index = _langCombo.AddString(GetSystemString(name));
_langCombo.SetItemData(index, _paths.Size());
_paths.Add(GetSystemString(shortName));
if (g_LangID.CollateNoCase(GetSystemString(shortName)) == 0 ||
g_LangID.CollateNoCase(GetSystemString(filePath)) == 0)
_langCombo.SetCurSel(index);
}
}
}
return CPropertyPage::OnInit();
}
LONG CLangPage::OnApply()
{
int selectedIndex = _langCombo.GetCurSel();
int pathIndex = _langCombo.GetItemData(selectedIndex);
SaveRegLang(_paths[pathIndex]);
ReloadLang();
_langWasChanged = true;
return PSNRET_NOERROR;
}
void CLangPage::OnNotifyHelp()
{
ShowHelpWindow(NULL, kLangTopic); // change it
}
bool CLangPage::OnCommand(int code, int itemID, LPARAM param)
{
if (code == CBN_SELCHANGE && itemID == IDC_LANG_COMBO_LANG)
{
Changed();
return true;
}
return CPropertyPage::OnCommand(code, itemID, param);
}
|