-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathI18n.h
104 lines (81 loc) · 3.75 KB
/
I18n.h
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
// Clavier+
// Keyboard shortcuts manager
//
// Copyright (C) 2000-2008 Guillaume Ryder
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// Internationalization support. Relies on Windows resource localization system for storing
// translations of strings, icons, dialog boxes, etc. but does not use SetThreadLocale() to set the
// current language. Indeed, this function has a strange behavior with some locales (e.g. US Windows
// versions with French locale) so we prefer using our own resource loading functions so that we can
// chose exactly the locale we want for a resources.
#pragma once
class String;
namespace i18n {
enum Language {
kLangDE, // German - Deutsch
kLangEN, // English
kLangES, // Spanish - Español (Venezuela)
kLangFR, // French - Français
kLangIT, // Italian - Italiano
kLangHU, // Hungarian - Magyar
kLangNL, // Dutch - Nederlands (België)
kLangPL, // Polish - Polski
kLangPT, // Portuguese - Português brasileiro
kLangSK, // Slovak - Slovenčina
kLangFI, // Finnish - Suomi
kLangEL, // Greek - Ελληνικά
kLangRU, // Russian - Русский
kLangZH_CN, // Simplified Chinese - 简体中文
kLangZH_TW, // Traditional Chinese - 繁體中文
kLangJA, // Japanese - 日本語
kLangCount,
kLangDefault = kLangEN,
};
Language getLanguage();
void setLanguage(Language lang);
Language getDefaultLanguage();
LPCTSTR getLanguageDonateUrl();
// Memory representation of a string resource. Should only be used for low-level string resource
// loading, when callers need to know the string length.
struct STRING_RESOURCE {
WORD length;
WCHAR strbuf[] SUPPRESS_WARNING(4200);
void copy(LPTSTR dest_strbuf, int buf_length) const {
StringCchCopy(dest_strbuf, buf_length, strbuf);
}
};
// Loads a string for getLanguage() locale.
const STRING_RESOURCE* loadStringResource(UINT id);
// Loads a string for getLanguage() locale. Copies it to the supplied string buffer.
void loadString(UINT id, LPTSTR strbuf, int buf_length);
// Loads a string for getLanguage() locale. Copies it to the supplied statically allocated string
// buffer. Should not be used on dynamically allocated string buffers.
#define loadStringAuto(id, strbuf) \
loadString(id, strbuf, arrayLength(strbuf))
// Displays a modal dialog box loaded from a resource, for getLanguage() locale. Sets e_hdlgModal
// before displaying the dialog box, restores it to its previous value when the dialog is closed.
INT_PTR dialogBox(UINT id, HWND hwnd_parent, DLGPROC window_proc, LPARAM init_param = 0);
// Loads a menu from a resource, for getLanguage() locale.
HMENU loadMenu(UINT id);
// Loads a bitmap from a resource, for getLanguage() locale.
HBITMAP loadBitmap(UINT id);
// Loads a neutral locale icon from a resource.
HICON loadNeutralIcon(UINT id, int cx, int cy);
const size_t kIntegerBufSize = 40;
// Formats a number with the default i18n format.
void formatInteger(int number, String* output);
// Converts a LOCALE_SGROUPING string into its NUMBERFMT.Grouping equivalent.
UINT parseNumberGroupingString(LPCTSTR input);
} // namespace i18n