mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +00:00
LibUnicode: Check whether a calendar symbol for a locale actually exists
In the generated unique string list, index 0 is the empty string, and is used to indicate a value doesn't exist in the CLDR. Check for this before returning an empty calendar symbol. For example, an upcoming commit will add the fixed day period "noon", which not all locales support.
This commit is contained in:
parent
0f26ab89ae
commit
16b673eaa9
Notes:
sideshowbarker
2024-07-17 08:40:35 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/16b673eaa9 Pull-request: https://github.com/SerenityOS/serenity/pull/14637 Reviewed-by: https://github.com/linusg ✅
1 changed files with 16 additions and 8 deletions
|
@ -2240,8 +2240,10 @@ Optional<StringView> get_calendar_era_symbol(StringView locale, StringView calen
|
|||
{
|
||||
auto symbols = find_calendar_symbols(locale, calendar, CalendarSymbol::Era, style);
|
||||
|
||||
if (auto value_index = to_underlying(value); value_index < symbols.size())
|
||||
return s_string_list[symbols.at(value_index)];
|
||||
if (auto value_index = to_underlying(value); value_index < symbols.size()) {
|
||||
if (auto symbol_index = symbols.at(value_index); symbol_index != 0)
|
||||
return s_string_list[symbol_index];
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -2250,8 +2252,10 @@ Optional<StringView> get_calendar_month_symbol(StringView locale, StringView cal
|
|||
{
|
||||
auto symbols = find_calendar_symbols(locale, calendar, CalendarSymbol::Month, style);
|
||||
|
||||
if (auto value_index = to_underlying(value); value_index < symbols.size())
|
||||
return s_string_list[symbols.at(value_index)];
|
||||
if (auto value_index = to_underlying(value); value_index < symbols.size()) {
|
||||
if (auto symbol_index = symbols.at(value_index); symbol_index != 0)
|
||||
return s_string_list[symbol_index];
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -2260,8 +2264,10 @@ Optional<StringView> get_calendar_weekday_symbol(StringView locale, StringView c
|
|||
{
|
||||
auto symbols = find_calendar_symbols(locale, calendar, CalendarSymbol::Weekday, style);
|
||||
|
||||
if (auto value_index = to_underlying(value); value_index < symbols.size())
|
||||
return s_string_list[symbols.at(value_index)];
|
||||
if (auto value_index = to_underlying(value); value_index < symbols.size()) {
|
||||
if (auto symbol_index = symbols.at(value_index); symbol_index != 0)
|
||||
return s_string_list[symbol_index];
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -2270,8 +2276,10 @@ Optional<StringView> get_calendar_day_period_symbol(StringView locale, StringVie
|
|||
{
|
||||
auto symbols = find_calendar_symbols(locale, calendar, CalendarSymbol::DayPeriod, style);
|
||||
|
||||
if (auto value_index = to_underlying(value); value_index < symbols.size())
|
||||
return s_string_list[symbols.at(value_index)];
|
||||
if (auto value_index = to_underlying(value); value_index < symbols.size()) {
|
||||
if (auto symbol_index = symbols.at(value_index); symbol_index != 0)
|
||||
return s_string_list[symbol_index];
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue