2018-10-07 03:40:45 +00:00
|
|
|
#pragma once
|
2019-07-20 04:25:01 +00:00
|
|
|
#include <type_traits>
|
|
|
|
#include <string_view>
|
|
|
|
#include <vector>
|
2018-04-30 16:56:14 +00:00
|
|
|
|
2019-07-20 04:25:01 +00:00
|
|
|
#include <fmt/format.h>
|
2018-04-30 16:56:14 +00:00
|
|
|
|
2019-07-20 04:25:01 +00:00
|
|
|
namespace locale {
|
|
|
|
using namespace std::literals;
|
|
|
|
#include <locales-inl.hpp>
|
|
|
|
|
|
|
|
struct DoGetName {
|
|
|
|
template <typename L>
|
|
|
|
constexpr auto Do() { return L::Name; }
|
|
|
|
};
|
|
|
|
constexpr auto GetName(ELocale l) {
|
|
|
|
return Do(l, DoGetName());
|
|
|
|
}
|
|
|
|
|
|
|
|
struct DoGetFullName {
|
|
|
|
template <typename L>
|
|
|
|
constexpr auto Do() { return L::FullName; }
|
|
|
|
};
|
|
|
|
constexpr auto GetFullName(ELocale l) {
|
|
|
|
return Do(l, DoGetFullName());
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Key>
|
|
|
|
struct DoTranslate {
|
|
|
|
template <typename L, typename... Args>
|
|
|
|
constexpr auto Do(Args&&... args) { return fmt::format(Lookup<L, Key>::Value(), std::forward<Args>(args)...); }
|
|
|
|
};
|
|
|
|
template <typename Key, typename... Args>
|
|
|
|
constexpr auto Translate(ELocale l, Args&&... args) {
|
|
|
|
return Do(l, DoTranslate<Key>(), std::forward<Args>(args)...);
|
|
|
|
}
|
2018-04-30 16:56:14 +00:00
|
|
|
|
|
|
|
std::vector<std::pair<std::string_view, std::string_view>> ListLocales();
|
2019-07-20 04:25:01 +00:00
|
|
|
ELocale LookupLocale(std::string_view name);
|
|
|
|
ELocale SystemLocaleOrEnglish();
|
2018-04-30 16:56:14 +00:00
|
|
|
|
2019-07-20 04:25:01 +00:00
|
|
|
} // namespace locale
|