mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:07:34 +00:00
LibUnicode: Add public accessors to generated locale data
This commit is contained in:
parent
b7a95cba65
commit
137e98cb6f
2 changed files with 41 additions and 0 deletions
|
@ -11,6 +11,10 @@
|
|||
#include <AK/StringBuilder.h>
|
||||
#include <LibUnicode/Locale.h>
|
||||
|
||||
#if ENABLE_UNICODE_DATA
|
||||
# include <LibUnicode/UnicodeLocale.h>
|
||||
#endif
|
||||
|
||||
namespace Unicode {
|
||||
|
||||
bool is_unicode_language_subtag(StringView subtag)
|
||||
|
@ -149,4 +153,36 @@ Optional<String> canonicalize_unicode_locale_id(LocaleID& locale_id)
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
String const& default_locale()
|
||||
{
|
||||
static String locale = "en"sv;
|
||||
return locale;
|
||||
}
|
||||
|
||||
bool is_locale_available([[maybe_unused]] StringView locale)
|
||||
{
|
||||
#if ENABLE_UNICODE_DATA
|
||||
static auto const& available_locales = Detail::available_locales();
|
||||
return available_locales.contains(locale);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
Optional<StringView> get_locale_territory_mapping([[maybe_unused]] StringView locale, [[maybe_unused]] StringView code)
|
||||
{
|
||||
#if ENABLE_UNICODE_DATA
|
||||
static auto const& available_locales = Detail::available_locales();
|
||||
|
||||
auto it = available_locales.find(locale);
|
||||
if (it == available_locales.end())
|
||||
return {};
|
||||
|
||||
if (auto territory = Detail::territory_from_string(code); territory.has_value())
|
||||
return it->value.territories[to_underlying(*territory)];
|
||||
#endif
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue