mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-23 01:32:14 -05:00
ebdb92eef6
LibLocale was split off from LibUnicode a couple years ago to reduce the number of applications on SerenityOS that depend on CLDR data. Now that we use ICU, both LibUnicode and LibLocale are actually linking in this data. And since vcpkg gives us static libraries, both libraries are over 30MB in size. This patch reverts the separation and merges LibLocale into LibUnicode again. We now have just one library that includes the ICU data. Further, this will let LibUnicode share the locale cache that previously would only exist in LibLocale.
75 lines
1.8 KiB
C++
75 lines
1.8 KiB
C++
/*
|
|
* Copyright (c) 2022-2024, Tim Flynn <trflynn89@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibUnicode/PluralRules.h>
|
|
|
|
namespace Unicode {
|
|
|
|
PluralForm plural_form_from_string(StringView plural_form)
|
|
{
|
|
if (plural_form == "cardinal"sv)
|
|
return PluralForm::Cardinal;
|
|
if (plural_form == "ordinal"sv)
|
|
return PluralForm::Ordinal;
|
|
VERIFY_NOT_REACHED();
|
|
}
|
|
|
|
StringView plural_form_to_string(PluralForm plural_form)
|
|
{
|
|
switch (plural_form) {
|
|
case PluralForm::Cardinal:
|
|
return "cardinal"sv;
|
|
case PluralForm::Ordinal:
|
|
return "ordinal"sv;
|
|
}
|
|
VERIFY_NOT_REACHED();
|
|
}
|
|
|
|
PluralCategory plural_category_from_string(StringView category)
|
|
{
|
|
if (category == "other"sv)
|
|
return PluralCategory::Other;
|
|
if (category == "zero"sv)
|
|
return PluralCategory::Zero;
|
|
if (category == "one"sv)
|
|
return PluralCategory::One;
|
|
if (category == "two"sv)
|
|
return PluralCategory::Two;
|
|
if (category == "few"sv)
|
|
return PluralCategory::Few;
|
|
if (category == "many"sv)
|
|
return PluralCategory::Many;
|
|
if (category == "0"sv)
|
|
return PluralCategory::ExactlyZero;
|
|
if (category == "1"sv)
|
|
return PluralCategory::ExactlyOne;
|
|
VERIFY_NOT_REACHED();
|
|
}
|
|
|
|
StringView plural_category_to_string(PluralCategory category)
|
|
{
|
|
switch (category) {
|
|
case PluralCategory::Other:
|
|
return "other"sv;
|
|
case PluralCategory::Zero:
|
|
return "zero"sv;
|
|
case PluralCategory::One:
|
|
return "one"sv;
|
|
case PluralCategory::Two:
|
|
return "two"sv;
|
|
case PluralCategory::Few:
|
|
return "few"sv;
|
|
case PluralCategory::Many:
|
|
return "many"sv;
|
|
case PluralCategory::ExactlyZero:
|
|
return "0"sv;
|
|
case PluralCategory::ExactlyOne:
|
|
return "1"sv;
|
|
}
|
|
VERIFY_NOT_REACHED();
|
|
}
|
|
|
|
}
|