Pioneer
Loading...
Searching...
No Matches
Lang.h
Go to the documentation of this file.
1// Copyright © 2008-2023 Pioneer Developers. See AUTHORS.txt for details
2// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
3
4#ifndef _LANG_H
5#define _LANG_H
6
7#include "IterationProxy.h"
8#include <SDL_stdinc.h>
9#include <map>
10#include <string>
11#include <vector>
12
13namespace Lang {
14
15 class Resource {
16 public:
17 Resource(const std::string &name, const std::string &langCode) :
18 m_name(name),
19 m_langCode(langCode),
20 m_loaded(false) {}
21
22 const std::string &GetName() const { return m_name; }
23 const std::string &GetLangCode() const { return m_langCode; }
24
25 bool Load();
26
27 Uint32 GetNumStrings() const { return static_cast<Uint32>(m_strings.size()); }
28
29 const std::string &Get(const std::string &token) const;
30
31 static std::vector<std::string> GetAvailableLanguages(const std::string &resourceName);
32
35
36 private:
37 std::string m_name;
38 std::string m_langCode;
39
40 bool m_loaded;
41
42 std::map<std::string, std::string> m_strings;
43 };
44
45// declare all strings
46#define DECLARE_STRING(x) extern char x[];
47#include "LangStrings.inc.h"
48#undef DECLARE_STRING
49
50 void MakeCore(Resource &res);
51 const Resource &GetCore();
52
53 Resource GetResource(const std::string &name, const std::string &langCode);
54
55} // namespace Lang
56
57#endif
IterationProxy< Container > MakeIterationProxy(Container &container)
Definition IterationProxy.h:51
Definition IterationProxy.h:13
Definition Lang.h:15
IterationProxy< std::map< std::string, std::string > > GetStrings()
Definition Lang.h:33
Uint32 GetNumStrings() const
Definition Lang.h:27
bool Load()
Definition Lang.cpp:36
const std::string & Get(const std::string &token) const
Definition Lang.cpp:107
const std::string & GetName() const
Definition Lang.h:22
const IterationProxy< const std::map< std::string, std::string > > GetStrings() const
Definition Lang.h:34
Resource(const std::string &name, const std::string &langCode)
Definition Lang.h:17
static std::vector< std::string > GetAvailableLanguages(const std::string &resourceName)
Definition Lang.cpp:117
const std::string & GetLangCode() const
Definition Lang.h:23
Definition Lang.cpp:15
void MakeCore(Resource &res)
Definition Lang.cpp:170
Resource GetResource(const std::string &name, const std::string &langCode)
Definition Lang.cpp:205
const Resource & GetCore()
Definition Lang.cpp:198