2015-12-06 01:24:51 +00:00
|
|
|
#ifndef SPECTER_TRANSLATOR_HPP
|
|
|
|
#define SPECTER_TRANSLATOR_HPP
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <Athena/DNAYaml.hpp>
|
|
|
|
|
|
|
|
namespace Specter
|
|
|
|
{
|
|
|
|
|
|
|
|
class Locale
|
|
|
|
{
|
|
|
|
std::string m_name;
|
|
|
|
std::string m_fullName;
|
|
|
|
std::unique_ptr<Athena::io::YAMLNode> m_rootNode;
|
2015-12-31 03:19:03 +00:00
|
|
|
const Athena::io::YAMLNode* m_langNode;
|
2015-12-06 01:24:51 +00:00
|
|
|
public:
|
|
|
|
Locale(const std::string& name, const std::string& fullName,
|
|
|
|
const unsigned char* yamlSource, size_t yamlLength);
|
|
|
|
const std::string& name() const {return m_name;}
|
|
|
|
const std::string& fullName() const {return m_fullName;}
|
2016-01-05 22:03:40 +00:00
|
|
|
const Athena::io::YAMLNode* rootNode() const {return m_langNode;}
|
2015-12-06 01:24:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Translator
|
|
|
|
{
|
|
|
|
const Locale* m_targetLocale;
|
|
|
|
public:
|
|
|
|
Translator(const Locale* targetLocale) {setLocale(targetLocale);}
|
|
|
|
void setLocale(const Locale* targetLocale);
|
2015-12-31 03:19:03 +00:00
|
|
|
const std::string* translate(const std::string& key) const;
|
|
|
|
std::string translateOr(const std::string& key, const char* vor) const;
|
2015-12-06 01:24:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // SPECTER_TRANSLATOR_HPP
|