mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:57:34 +00:00
LibUnicode: Parse and generate the Unicode locale list patterns dataset
This data informs consumers how to join lists of values. For example, in en-US, the list ["a", "b", "c"] formatted to a string should become "a, b, and c".
This commit is contained in:
parent
9cd986d8c0
commit
3f64a14e06
4 changed files with 172 additions and 10 deletions
|
@ -13,6 +13,8 @@ namespace Unicode {
|
|||
enum class Condition : u8;
|
||||
enum class GeneralCategory : u8;
|
||||
enum class Language : u8;
|
||||
enum class ListPatternStyle : u8;
|
||||
enum class ListPatternType : u8;
|
||||
enum class Locale : u16;
|
||||
enum class Property : u8;
|
||||
enum class Script : u8;
|
||||
|
@ -21,6 +23,7 @@ enum class WordBreakProperty : u8;
|
|||
|
||||
struct Keyword;
|
||||
struct LanguageID;
|
||||
struct ListPatterns;
|
||||
struct LocaleExtension;
|
||||
struct LocaleID;
|
||||
struct OtherExtension;
|
||||
|
|
|
@ -798,6 +798,15 @@ Optional<StringView> get_locale_currency_mapping([[maybe_unused]] StringView loc
|
|||
#endif
|
||||
}
|
||||
|
||||
Optional<ListPatterns> get_locale_list_patterns([[maybe_unused]] StringView locale, [[maybe_unused]] StringView type, [[maybe_unused]] StringView style)
|
||||
{
|
||||
#if ENABLE_UNICODE_DATA
|
||||
return Detail::get_locale_list_pattern_mapping(locale, type, style);
|
||||
#else
|
||||
return {};
|
||||
#endif
|
||||
}
|
||||
|
||||
Optional<StringView> resolve_language_alias(StringView language)
|
||||
{
|
||||
#if ENABLE_UNICODE_DATA
|
||||
|
|
|
@ -78,6 +78,13 @@ struct LocaleID {
|
|||
Vector<String> private_use_extensions {};
|
||||
};
|
||||
|
||||
struct ListPatterns {
|
||||
StringView start;
|
||||
StringView middle;
|
||||
StringView end;
|
||||
StringView pair;
|
||||
};
|
||||
|
||||
// Note: These methods only verify that the provided strings match the EBNF grammar of the
|
||||
// Unicode identifier subtag (i.e. no validation is done that the tags actually exist).
|
||||
constexpr bool is_unicode_language_subtag(StringView subtag)
|
||||
|
@ -130,6 +137,7 @@ Optional<StringView> get_locale_language_mapping(StringView locale, StringView l
|
|||
Optional<StringView> get_locale_territory_mapping(StringView locale, StringView territory);
|
||||
Optional<StringView> get_locale_script_mapping(StringView locale, StringView script);
|
||||
Optional<StringView> get_locale_currency_mapping(StringView locale, StringView currency);
|
||||
Optional<ListPatterns> get_locale_list_patterns(StringView locale, StringView type, StringView style);
|
||||
|
||||
Optional<StringView> resolve_language_alias(StringView language);
|
||||
Optional<StringView> resolve_territory_alias(StringView territory);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue