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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
/*
* The ManaPlus Client
* Copyright (C) 2009-2010 Andrei Karas
* Copyright (C) 2011-2014 The ManaPlus Developers
*
* This file is part of The ManaPlus Client.
*
* 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 2 of the License, or
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef GUI_MODELS_LANGLISTMODEL_H
#define GUI_MODELS_LANGLISTMODEL_H
#include "gui/models/extendedlistmodel.h"
#include "resources/resourcemanager.h"
#include "utils/gettext.h"
#include "localconsts.h"
struct Language final
{
std::string name;
std::string value;
std::string icon;
};
const int langs_count = 18;
const Language LANG_NAME[langs_count] =
{
// TRANSLATORS: language
{N_("(default)"), "", ""},
// TRANSLATORS: language
{N_("Chinese (China)"), "zh_CN", "cn.png"},
// TRANSLATORS: language
{N_("Czech"), "cs_CZ", "cz.png"},
// TRANSLATORS: language
{N_("English"), "C", "en.png"},
// TRANSLATORS: language
{N_("Finnish"), "fi_FI", "fi.png"},
// TRANSLATORS: language
{N_("French"), "fr_FR", "fr.png"},
// TRANSLATORS: language
{N_("German"), "de_DE", "de.png"},
// TRANSLATORS: language
{N_("Indonesian"), "id_ID", "id.png"},
// TRANSLATORS: language
{N_("Italian"), "it_IT", "it.png"},
// TRANSLATORS: language
{N_("Polish"), "pl_PL", "pl.png"},
// TRANSLATORS: language
{N_("Japanese"), "ja_JP", "jp.png"},
// TRANSLATORS: language
{N_("Dutch (Belgium/Flemish)"), "nl_BE", "nl_BE.png"},
// TRANSLATORS: language
{N_("Portuguese"), "pt_PT", "pt.png"},
// TRANSLATORS: language
{N_("Portuguese (Brazilian)"), "pt_BR", "pt_BR.png"},
// TRANSLATORS: language
{N_("Russian"), "ru_RU", "ru.png"},
// TRANSLATORS: language
{N_("Spanish (Castilian)"), "es_ES", "es.png"},
// TRANSLATORS: language
{N_("Swedish (Sweden)"), "sv_SE", "se.png"},
// TRANSLATORS: language
{N_("Turkish"), "tr_TR", "tr.png"}
};
class LangListModel final : public ExtendedListModel
{
public:
LangListModel()
{
ResourceManager *const resman = ResourceManager::getInstance();
for (int f = 0; f < langs_count; f ++)
{
mIcons[f] = resman->getImage("graphics/flags/"
+ LANG_NAME[f].icon);
}
}
A_DELETE_COPY(LangListModel)
~LangListModel()
{
for (int f = 0; f < langs_count; f ++)
{
Image *const img = mIcons[f];
if (img)
img->decRef();
}
}
int getNumberOfElements() override final A_WARN_UNUSED
{ return langs_count; }
std::string getElementAt(int i) override final A_WARN_UNUSED
{
if (i >= getNumberOfElements() || i < 0)
return "???";
return gettext(LANG_NAME[i].name.c_str());
}
const Image *getImageAt(int i) override final A_WARN_UNUSED
{
if (i >= getNumberOfElements() || i < 0)
return nullptr;
return mIcons[i];
}
Image *mIcons[langs_count];
};
#endif // GUI_MODELS_LANGLISTMODEL_H
|