1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 22:38:13 +00:00

LibJS+LibUnicode: Separate number formatting methods from Locale.h

Currently, we generate separate data files for locale and number format
related tables/methods, but provide public accessors for all of the data
in one Locale.h file. Rather than continuing this trend for date-time,
relative time, etc. formatting, it's a bit easier to reason about if the
public accessors are also in separate files.
This commit is contained in:
Timothy Flynn 2021-11-27 10:53:42 -05:00 committed by Linus Groh
parent bb11437792
commit 914675e826
8 changed files with 216 additions and 178 deletions

View file

@ -85,46 +85,6 @@ enum class Style : u8 {
Numeric,
};
struct NumberGroupings {
u8 primary_grouping_size { 0 };
u8 secondary_grouping_size { 0 };
};
enum class StandardNumberFormatType : u8 {
Decimal,
Currency,
Accounting,
Percent,
Scientific,
};
enum class CompactNumberFormatType : u8 {
DecimalLong,
DecimalShort,
CurrencyUnit,
CurrencyShort,
};
struct NumberFormat {
enum class Plurality : u8 {
Other,
Zero,
Single,
One,
Two,
Few,
Many,
};
u8 magnitude { 0 };
u8 exponent { 0 };
Plurality plurality { Plurality::Other };
StringView zero_format {};
StringView positive_format {};
StringView negative_format {};
Vector<StringView> identifiers {};
};
struct ListPatterns {
StringView start;
StringView middle;
@ -188,10 +148,6 @@ Optional<StringView> get_locale_script_mapping(StringView locale, StringView scr
Optional<StringView> get_locale_currency_mapping(StringView locale, StringView currency, Style style);
Vector<StringView> get_locale_key_mapping(StringView locale, StringView keyword);
Optional<StringView> get_number_system_symbol(StringView locale, StringView system, StringView symbol);
Optional<NumberGroupings> get_number_system_groupings(StringView locale, StringView system);
Optional<NumberFormat> get_standard_number_system_format(StringView locale, StringView system, StandardNumberFormatType type);
Vector<NumberFormat> get_compact_number_system_formats(StringView locale, StringView system, CompactNumberFormatType type);
Vector<NumberFormat> get_unit_formats(StringView locale, StringView unit, Style style);
Optional<ListPatterns> get_locale_list_patterns(StringView locale, StringView type, StringView style);
Optional<StringView> resolve_language_alias(StringView language);
@ -204,7 +160,4 @@ Optional<LanguageID> add_likely_subtags(LanguageID const& language_id);
Optional<LanguageID> remove_likely_subtags(LanguageID const& language_id);
String resolve_most_likely_territory(LanguageID const& language_id, StringView territory_alias);
Optional<NumberFormat> select_pattern_with_plurality(Vector<NumberFormat> const& formats, double number);
Optional<String> augment_currency_format_pattern(StringView currency_display, StringView base_pattern);
}