2022-01-28 12:56:04 -05:00
|
|
|
/*
|
2022-01-31 13:07:22 -05:00
|
|
|
* Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
|
2022-01-28 12:56:04 -05:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/String.h>
|
|
|
|
#include <AK/StringView.h>
|
|
|
|
#include <LibJS/Runtime/Intl/NumberFormat.h>
|
|
|
|
#include <LibJS/Runtime/Object.h>
|
2022-07-07 09:58:36 -04:00
|
|
|
#include <LibUnicode/PluralRules.h>
|
2022-01-28 12:56:04 -05:00
|
|
|
|
|
|
|
namespace JS::Intl {
|
|
|
|
|
|
|
|
class PluralRules final : public NumberFormatBase {
|
|
|
|
JS_OBJECT(PluralRules, NumberFormatBase);
|
|
|
|
|
|
|
|
public:
|
|
|
|
PluralRules(Object& prototype);
|
|
|
|
virtual ~PluralRules() override = default;
|
|
|
|
|
2022-07-07 09:58:36 -04:00
|
|
|
Unicode::PluralForm type() const { return m_type; }
|
|
|
|
StringView type_string() const { return Unicode::plural_form_to_string(m_type); }
|
|
|
|
void set_type(StringView type) { m_type = Unicode::plural_form_from_string(type); }
|
2022-01-28 12:56:04 -05:00
|
|
|
|
|
|
|
private:
|
2022-07-07 09:58:36 -04:00
|
|
|
Unicode::PluralForm m_type { Unicode::PluralForm::Cardinal }; // [[Type]]
|
2022-01-28 12:56:04 -05:00
|
|
|
};
|
|
|
|
|
2022-07-07 10:01:00 -04:00
|
|
|
Unicode::PluralOperands get_operands(String const& string);
|
|
|
|
Unicode::PluralCategory plural_rule_select(StringView locale, Unicode::PluralForm type, Value number, Unicode::PluralOperands operands);
|
|
|
|
Unicode::PluralCategory resolve_plural(GlobalObject& global_object, PluralRules const& plural_rules, Value number);
|
2022-07-08 11:52:18 -04:00
|
|
|
Unicode::PluralCategory resolve_plural(GlobalObject& global_object, NumberFormatBase const& number_format, Unicode::PluralForm type, Value number);
|
2022-07-07 10:01:00 -04:00
|
|
|
|
2022-01-28 12:56:04 -05:00
|
|
|
}
|