Repository navigation
Expand file tree
/
Copy pathLanguage.h
More file actions
79 lines (73 loc) · 2.59 KB
/
Copy pathLanguage.h
File metadata and controls
79 lines (73 loc) · 2.59 KB
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
/*
* Copyright 2010-2013 OpenXcom Developers.
*
* This file is part of OpenXcom.
*
* OpenXcom 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.
*
* OpenXcom 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.
*e
* You should have received a copy of the GNU General Public License
* along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPENXCOM_LANGUAGE_H
#define OPENXCOM_LANGUAGE_H
#include <map>
#include <vector>
#include <string>
#include "LocalizedText.h"
#include "../Savegame/Soldier.h"
namespace OpenXcom
{
class TextList;
/**
* Contains strings used throughout the game for localization.
* Languages are just a set of strings identified by an ID string.
*/
class Language
{
public:
class PluralityRules;
/// Creates a blank language.
Language();
/// Cleans up the language.
~Language();
/// Converts a wide-string to UTF-8.
static std::string wstrToUtf8(const std::wstring& src);
/// Converts a wide-string to local-codepage string.
static std::string wstrToCp(const std::wstring &src);
/// Converts a UTF-8 string to wide-string.
static std::wstring utf8ToWstr(const std::string& src);
/// Converts a local-codepage string to wide-string.
static std::wstring cpToWstr(const std::string& src);
/// Replaces a substring.
static void replace(std::string &str, const std::string &find, const std::string &replace);
/// Replaces a substring.
static void replace(std::wstring &str, const std::wstring &find, const std::wstring &replace);
/// Gets list of languages in the data directory.
static std::vector<std::string> getList(TextList *list);
/// Loads an OpenXcom language file.
void loadLng(const std::string &filename);
/// Gets the language's name.
std::wstring getName() const;
/// Outputs the language to a HTML file.
void toHtml(const std::string &filename) const;
/// Get a localized text.
const LocalizedText &getString(const std::string &id) const;
/// Get a quantity-depended localized text.
LocalizedText getString(const std::string &id, unsigned n) const;
/// Get a gender-depended localized text.
const LocalizedText &getString(const std::string &id, SoldierGender gender) const;
private:
std::wstring _name;
std::map<std::string, LocalizedText> _strings;
PluralityRules *_handler;
};
}
#endif