metaforce/Editor/locale/locale.hpp

43 lines
1.0 KiB
C++
Raw Normal View History

2018-10-06 20:40:45 -07:00
#pragma once
2019-07-19 21:25:01 -07:00
#include <type_traits>
#include <string_view>
#include <vector>
2018-04-30 09:56:14 -07:00
2019-07-19 21:25:01 -07:00
#include <fmt/format.h>
2018-04-30 09:56:14 -07:00
2019-07-19 21:25:01 -07: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 09:56:14 -07:00
std::vector<std::pair<std::string_view, std::string_view>> ListLocales();
2019-07-19 21:25:01 -07:00
ELocale LookupLocale(std::string_view name);
ELocale SystemLocaleOrEnglish();
2018-04-30 09:56:14 -07:00
2019-07-19 21:25:01 -07:00
} // namespace locale