pioneer/src/Lang.h

58 lines
1.4 KiB
C
Raw Normal View History

2020-12-31 07:32:16 -08:00
// Copyright © 2008-2021 Pioneer Developers. See AUTHORS.txt for details
2012-09-15 17:59:15 -07:00
// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
2012-09-12 04:38:30 -07:00
#ifndef _LANG_H
#define _LANG_H
#include "IterationProxy.h"
#include <SDL_stdinc.h>
#include <map>
#include <string>
#include <vector>
namespace Lang {
class Resource {
public:
Resource(const std::string &name, const std::string &langCode) :
m_name(name),
m_langCode(langCode),
m_loaded(false) {}
const std::string &GetName() const { return m_name; }
const std::string &GetLangCode() const { return m_langCode; }
bool Load();
Uint32 GetNumStrings() const { return static_cast<Uint32>(m_strings.size()); }
const std::string &Get(const std::string &token) const;
static std::vector<std::string> GetAvailableLanguages(const std::string &resourceName);
IterationProxy<std::map<std::string, std::string>> GetStrings() { return MakeIterationProxy(m_strings); }
const IterationProxy<const std::map<std::string, std::string>> GetStrings() const { return MakeIterationProxy(m_strings); }
2013-10-22 14:48:36 -07:00
private:
std::string m_name;
std::string m_langCode;
bool m_loaded;
std::map<std::string, std::string> m_strings;
};
// declare all strings
#define DECLARE_STRING(x) extern char x[];
#include "LangStrings.inc.h"
#undef DECLARE_STRING
void MakeCore(Resource &res);
const Resource &GetCore();
Resource GetResource(const std::string &name, const std::string &langCode);
} // namespace Lang
#endif