
The PluralCategory enum is currently generated for plural rules. Instead of generating it, this moves the enum to the public LibUnicode header. While it was nice to auto-discover these values, they are well defined by TR-35, and we will need their values from within the number format code generator (which can't rely on the plural rules generator having run yet). Further, number format will require additional values in the enum that plural rules doesn't know about.
43 lines
1 KiB
C++
43 lines
1 KiB
C++
/*
|
|
* Copyright (c) 2022, 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;
|
|
default:
|
|
VERIFY_NOT_REACHED();
|
|
}
|
|
}
|
|
|
|
PluralCategory __attribute__((weak)) determine_plural_category(StringView, PluralForm, PluralOperands)
|
|
{
|
|
return PluralCategory::Other;
|
|
}
|
|
|
|
Span<PluralCategory const> __attribute__((weak)) available_plural_categories(StringView, PluralForm)
|
|
{
|
|
static constexpr Array<PluralCategory, 1> categories { { PluralCategory::Other } };
|
|
return categories.span();
|
|
}
|
|
|
|
}
|