1 // Copyright 2014 Idol Software, Inc.
3 // This file is part of Doctor Dump SDK.
5 // Doctor Dump SDK is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "Translator.h"
21 static const wchar_t* DefaultSection
= L
"crashhandler";
23 Translator::Translator(const wchar_t* appName
, const wchar_t* company
, HMODULE hImage
, DWORD resId
, const wchar_t* path
)
26 , m_default(hImage
, resId
)
29 m_custom
.reset(new IniFile(path
));
30 // if (WINVER >= 0x0600) Use LOCALE_SNAME en-us
31 // LOCALE_SISO639LANGNAME returns en
32 GetLocaleInfoW(LOCALE_USER_DEFAULT
, LOCALE_SISO639LANGNAME
, m_userLanguage
.GetBuffer(1024), 1024);
33 m_userLanguage
.ReleaseBuffer(-1);
34 m_userLanguage
= DefaultSection
+ (L
"-" + m_userLanguage
);
37 CStringW
Translator::GetString(const wchar_t* variable
)
42 result
= m_custom
->GetString(m_userLanguage
, variable
);
44 result
= m_custom
->GetString(DefaultSection
, variable
);
47 result
= m_default
.GetString(m_userLanguage
, variable
);
49 result
= m_default
.GetString(DefaultSection
, variable
);
51 MessageBoxW(0, variable
, L
"Doesn't translated string", MB_ICONERROR
);
53 result
.Replace(L
"\\n", L
"\n");
54 result
.Replace(L
"[AppName]", m_appName
);
55 result
.Replace(L
"[Company]", m_company
);