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
109
110
111
112
113
114
|
// LangPage.cpp
#include "StdAfx.h"
#include "../../../Common/Lang.h"
#include "../../../Windows/FileFind.h"
#include "../../../Windows/ResourceString.h"
#include "HelpUtils.h"
#include "LangPage.h"
#include "LangPageRes.h"
#include "LangUtils.h"
#include "RegistryUtils.h"
using namespace NWindows;
static const UInt32 kLangIDs[] =
{
IDT_LANG_LANG
};
static LPCWSTR kLangTopic = L"fm/options.htm#language";
static void NativeLangString(UString &dest, const wchar_t *s)
{
dest += L" (";
dest += s;
dest += L')';
}
bool LangOpen(CLang &lang, CFSTR fileName);
bool CLangPage::OnInit()
{
LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs));
_langCombo.Attach(GetItem(IDC_LANG_LANG));
UString temp = MyLoadString(IDS_LANG_ENGLISH);
NativeLangString(temp, MyLoadString(IDS_LANG_NATIVE));
int index = (int)_langCombo.AddString(temp);
_langCombo.SetItemData(index, _paths.Size());
_paths.Add(L"-");
_langCombo.SetCurSel(0);
const FString dirPrefix = GetLangDirPrefix();
NFile::NFind::CEnumerator enumerator(dirPrefix + FTEXT("*.txt"));
NFile::NFind::CFileInfo fi;
CLang lang;
UString error;
while (enumerator.Next(fi))
{
if (fi.IsDir())
continue;
const int kExtSize = 4;
if (fi.Name.Len() < kExtSize)
continue;
unsigned pos = fi.Name.Len() - kExtSize;
if (!StringsAreEqualNoCase_Ascii(fi.Name.Ptr(pos), ".txt"))
continue;
if (!LangOpen(lang, dirPrefix + fi.Name))
{
if (!error.IsEmpty())
error += L' ';
error += fs2us(fi.Name);
continue;
}
const UString shortName = fs2us(fi.Name.Left(pos));
UString s = shortName;
const wchar_t *eng = lang.Get(IDS_LANG_ENGLISH);
if (eng)
s = eng;
const wchar_t *native = lang.Get(IDS_LANG_NATIVE);
if (native)
NativeLangString(s, native);
index = (int)_langCombo.AddString(s);
_langCombo.SetItemData(index, _paths.Size());
_paths.Add(shortName);
if (g_LangID.IsEqualToNoCase(shortName))
_langCombo.SetCurSel(index);
}
if (!error.IsEmpty())
MessageBoxW(0, error, L"Error in Lang file", MB_OK | MB_ICONSTOP);
return CPropertyPage::OnInit();
}
LONG CLangPage::OnApply()
{
int pathIndex = (int)_langCombo.GetItemData_of_CurSel();
SaveRegLang(_paths[pathIndex]);
ReloadLang();
LangWasChanged = true;
return PSNRET_NOERROR;
}
void CLangPage::OnNotifyHelp()
{
ShowHelpWindow(NULL, kLangTopic);
}
bool CLangPage::OnCommand(int code, int itemID, LPARAM param)
{
if (code == CBN_SELCHANGE && itemID == IDC_LANG_LANG)
{
Changed();
return true;
}
return CPropertyPage::OnCommand(code, itemID, param);
}
|