mirror of https://github.com/AxioDL/metaforce.git
New code style refactor
This commit is contained in:
parent
c7c046763a
commit
cb32cac2c0
|
@ -15,55 +15,45 @@ extern "C" size_t L_en_GB_SZ;
|
|||
extern "C" const uint8_t L_ja_JP[];
|
||||
extern "C" size_t L_ja_JP_SZ;
|
||||
|
||||
namespace urde
|
||||
{
|
||||
namespace urde {
|
||||
|
||||
using namespace std::literals;
|
||||
|
||||
static const specter::Locale Locales[] =
|
||||
{
|
||||
{"en_US"sv, "US English"sv, L_en_US, L_en_US_SZ},
|
||||
{"en_GB"sv, "British English"sv, L_en_GB, L_en_GB_SZ},
|
||||
{"ja_JP"sv, "Japanese"sv, L_ja_JP, L_ja_JP_SZ}
|
||||
};
|
||||
static const specter::Locale Locales[] = {{"en_US"sv, "US English"sv, L_en_US, L_en_US_SZ},
|
||||
{"en_GB"sv, "British English"sv, L_en_GB, L_en_GB_SZ},
|
||||
{"ja_JP"sv, "Japanese"sv, L_ja_JP, L_ja_JP_SZ}};
|
||||
|
||||
std::vector<std::pair<std::string_view, std::string_view>> ListLocales()
|
||||
{
|
||||
constexpr size_t localeCount = std::extent<decltype(Locales)>::value;
|
||||
std::vector<std::pair<std::string_view, std::string_view>> ret;
|
||||
ret.reserve(localeCount);
|
||||
for (size_t i=0 ; i<localeCount ; ++i)
|
||||
{
|
||||
const specter::Locale& l = Locales[i];
|
||||
ret.emplace_back(l.name(), l.fullName());
|
||||
}
|
||||
return ret;
|
||||
std::vector<std::pair<std::string_view, std::string_view>> ListLocales() {
|
||||
constexpr size_t localeCount = std::extent<decltype(Locales)>::value;
|
||||
std::vector<std::pair<std::string_view, std::string_view>> ret;
|
||||
ret.reserve(localeCount);
|
||||
for (size_t i = 0; i < localeCount; ++i) {
|
||||
const specter::Locale& l = Locales[i];
|
||||
ret.emplace_back(l.name(), l.fullName());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
const specter::Locale* LookupLocale(std::string_view name)
|
||||
{
|
||||
constexpr size_t localeCount = std::extent<decltype(Locales)>::value;
|
||||
for (size_t i=0 ; i<localeCount ; ++i)
|
||||
{
|
||||
const specter::Locale& l = Locales[i];
|
||||
if (!name.compare(l.name()))
|
||||
return &l;
|
||||
}
|
||||
return nullptr;
|
||||
const specter::Locale* LookupLocale(std::string_view name) {
|
||||
constexpr size_t localeCount = std::extent<decltype(Locales)>::value;
|
||||
for (size_t i = 0; i < localeCount; ++i) {
|
||||
const specter::Locale& l = Locales[i];
|
||||
if (!name.compare(l.name()))
|
||||
return &l;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const specter::Locale* SystemLocaleOrEnglish()
|
||||
{
|
||||
const char* sysLocale = std::setlocale(LC_ALL, nullptr);
|
||||
size_t sysLocaleLen = std::strlen(sysLocale);
|
||||
constexpr size_t localeCount = std::extent<decltype(Locales)>::value;
|
||||
for (size_t i=0 ; i<localeCount ; ++i)
|
||||
{
|
||||
const specter::Locale& l = Locales[i];
|
||||
if (!l.name().compare(0, std::min(l.name().size(), sysLocaleLen), sysLocale))
|
||||
return &l;
|
||||
}
|
||||
return Locales;
|
||||
const specter::Locale* SystemLocaleOrEnglish() {
|
||||
const char* sysLocale = std::setlocale(LC_ALL, nullptr);
|
||||
size_t sysLocaleLen = std::strlen(sysLocale);
|
||||
constexpr size_t localeCount = std::extent<decltype(Locales)>::value;
|
||||
for (size_t i = 0; i < localeCount; ++i) {
|
||||
const specter::Locale& l = Locales[i];
|
||||
if (!l.name().compare(0, std::min(l.name().size(), sysLocaleLen), sysLocale))
|
||||
return &l;
|
||||
}
|
||||
return Locales;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace urde
|
||||
|
|
|
@ -2,12 +2,10 @@
|
|||
|
||||
#include <specter/Translator.hpp>
|
||||
|
||||
namespace urde
|
||||
{
|
||||
namespace urde {
|
||||
|
||||
std::vector<std::pair<std::string_view, std::string_view>> ListLocales();
|
||||
const specter::Locale* LookupLocale(std::string_view name);
|
||||
const specter::Locale* SystemLocaleOrEnglish();
|
||||
|
||||
}
|
||||
|
||||
} // namespace urde
|
||||
|
|
Loading…
Reference in New Issue