4#include "Stroika/Foundation/StroikaPreComp.h"
9#include "Stroika/Foundation/Execution/Exceptions.h"
10#include "Stroika/Foundation/Execution/Throw.h"
26LocaleNotFoundException::LocaleNotFoundException (
const optional<String>& iso2LetterLanguageCode,
const optional<String>& iso2LetterTerritoryCode)
27 : RuntimeErrorException{(iso2LetterLanguageCode.has_value () or iso2LetterTerritoryCode.has_value ())
28 ?
"Locale ({}-{}) not found"_f(iso2LetterLanguageCode.value_or (
""sv), iso2LetterTerritoryCode.value_or (
""sv))
29 :
"Locale not found"_k}
49EnumSystemLocales(EnumLocalesProc, LCID_INSTALLED);
51BOOL CALLBACK EnumLocalesProc(LPTSTR lpLocaleString)
54 TCHAR szCurNam[STR_LEN];
59 uiCurLocale = uiConvertStrToInt(lpLocaleString);
61 GetLocaleInfo(uiCurLocale, LOCALE_SLANGUAGE, szCurName, STR_LEN);
69 vector<Characters::String> result;
71 IgnoreExceptionsForCall (result.push_back (
FindLocaleName (
"en"sv,
"us"sv)));
85 Execution::Throw (LocaleNotFoundException{iso2LetterLanguageCode, iso2LetterTerritoryCode});
90 using namespace Characters;
91 Require (iso2LetterLanguageCode.
length () == 2);
92 Require (iso2LetterTerritoryCode.
length () == 2);
94#if USE_NOISY_TRACE_IN_THIS_MODULE_
104 iso2LetterLanguageCode,
108 static const set<String> part2{
115 iso2LetterTerritoryCode,
119 static const set<String> part4{
123 for (
const auto& i1 : part1) {
124 for (
const auto& i2 : part2) {
125 for (
const auto& i3 : part3) {
126 for (
const auto& i4 : part4) {
127#if USE_NOISY_TRACE_IN_THIS_MODULE_
128 DbgTrace (
"***trying locale (i1 + i2 + i3 + i4)={}"_f, i1 + i2 + i3 + i4);
130 IgnoreExceptionsForCall (
return String::FromNarrowSDKString (locale{(i1 + i2 + i3 + i4).AsNarrowSDKString ().c_str ()}.name ()));
156 return locale{o->AsNarrowSDKString ().c_str ()};
String is like std::u32string, except it is much easier to use, often much more space efficient,...
nonvirtual size_t length() const noexcept
nonvirtual String ToUpperCase() const
nonvirtual string AsNarrowSDKString() const
nonvirtual String ToLowerCase() const
Characters::String FindLocaleName(const Characters::String &iso2LetterLanguageCode, const Characters::String &iso2LetterTerritoryCode)
Not all systems appear to follow the same naming conventions for locales, so help lookup.
optional< Characters::String > FindLocaleNameQuietly(const Characters::String &iso2LetterLanguageCode, const Characters::String &iso2LetterTerritoryCode)
Not all systems appear to follow the same naming conventions for locales, so help lookup.
vector< Characters::String > GetAvailableLocales()
List all installed locale names (names which can be passed to std::locale::CTOR)
locale GetPlatformDefaultLocale()
locale FindNamedLocale(const Characters::String &iso2LetterLanguageCode, const Characters::String &iso2LetterTerritoryCode)
Find the locale matching these properties (for exception trying)
void UsePlatformDefaultLocaleAsDefaultLocale()
Set the operating system locale into the current C++ locale used by locale functions (and most locale...
void Throw(T &&e2Throw)
identical to builtin C++ 'throw' except that it does helpful, type dependent DbgTrace() messages firs...