mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-07-03 23:55:52 +00:00
Merge branch 'master' of https://github.com/AxioDL/libSpecter
This commit is contained in:
commit
329be27c7d
@ -18,7 +18,7 @@ public:
|
|||||||
const unsigned char* yamlSource, size_t yamlLength);
|
const unsigned char* yamlSource, size_t yamlLength);
|
||||||
const std::string& name() const {return m_name;}
|
const std::string& name() const {return m_name;}
|
||||||
const std::string& fullName() const {return m_fullName;}
|
const std::string& fullName() const {return m_fullName;}
|
||||||
const Athena::io::YAMLNode& rootNode() const {return *m_langNode;}
|
const Athena::io::YAMLNode* rootNode() const {return m_langNode;}
|
||||||
};
|
};
|
||||||
|
|
||||||
class Translator
|
class Translator
|
||||||
|
@ -30,7 +30,7 @@ void Translator::setLocale(const Locale* targetLocale)
|
|||||||
m_targetLocale = targetLocale;
|
m_targetLocale = targetLocale;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const std::string* RecursiveLookup(const Athena::io::YAMLNode& node,
|
static const std::string* RecursiveLookup(const Athena::io::YAMLNode* node,
|
||||||
std::string::const_iterator start,
|
std::string::const_iterator start,
|
||||||
std::string::const_iterator end)
|
std::string::const_iterator end)
|
||||||
{
|
{
|
||||||
@ -38,13 +38,13 @@ static const std::string* RecursiveLookup(const Athena::io::YAMLNode& node,
|
|||||||
{
|
{
|
||||||
if (*it == '/')
|
if (*it == '/')
|
||||||
{
|
{
|
||||||
const Athena::io::YAMLNode* ch = node.findMapChild(std::string(start, it).c_str());
|
const Athena::io::YAMLNode* ch = node->findMapChild(std::string(start, it).c_str());
|
||||||
if (!ch)
|
if (!ch)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return RecursiveLookup(*ch, it+1, end);
|
return RecursiveLookup(ch, it+1, end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const Athena::io::YAMLNode* ch = node.findMapChild(std::string(start, end).c_str());
|
const Athena::io::YAMLNode* ch = node->findMapChild(std::string(start, end).c_str());
|
||||||
if (!ch)
|
if (!ch)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return &ch->m_scalarString;
|
return &ch->m_scalarString;
|
||||||
@ -52,7 +52,7 @@ static const std::string* RecursiveLookup(const Athena::io::YAMLNode& node,
|
|||||||
|
|
||||||
const std::string* Translator::translate(const std::string& key) const
|
const std::string* Translator::translate(const std::string& key) const
|
||||||
{
|
{
|
||||||
if ((&m_targetLocale->rootNode()) == nullptr)
|
if (!m_targetLocale->rootNode())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return RecursiveLookup(m_targetLocale->rootNode(), key.cbegin(), key.cend());
|
return RecursiveLookup(m_targetLocale->rootNode(), key.cbegin(), key.cend());
|
||||||
@ -60,10 +60,7 @@ const std::string* Translator::translate(const std::string& key) const
|
|||||||
|
|
||||||
std::string Translator::translateOr(const std::string& key, const char* vor) const
|
std::string Translator::translateOr(const std::string& key, const char* vor) const
|
||||||
{
|
{
|
||||||
if ((&m_targetLocale->rootNode()) == nullptr)
|
const std::string* find = translate(key);
|
||||||
return vor;
|
|
||||||
|
|
||||||
const std::string* find = RecursiveLookup(m_targetLocale->rootNode(), key.cbegin(), key.cend());
|
|
||||||
if (find)
|
if (find)
|
||||||
return *find;
|
return *find;
|
||||||
return vor;
|
return vor;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user