mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:27:35 +00:00
LibJS: Parse new Intl.DisplayNames "type" and "languageDisplay" options
Intl.DisplayNames v2 adds "calendar" and "dateTimeField" types, as well as a "languageDisplay" option for the "language" type. This just adds these options to the constructor.
This commit is contained in:
parent
853ccab9af
commit
71f7e67a20
6 changed files with 102 additions and 14 deletions
|
@ -1,11 +1,12 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Tim Flynn <trflynn89@pm.me>
|
||||
* Copyright (c) 2021-2022, Tim Flynn <trflynn89@pm.me>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
|
@ -28,6 +29,8 @@ class DisplayNames final : public Object {
|
|||
Region,
|
||||
Script,
|
||||
Currency,
|
||||
Calendar,
|
||||
DateTimeField,
|
||||
};
|
||||
|
||||
enum class Fallback {
|
||||
|
@ -36,6 +39,11 @@ class DisplayNames final : public Object {
|
|||
Code,
|
||||
};
|
||||
|
||||
enum class LanguageDisplay {
|
||||
Dialect,
|
||||
Standard,
|
||||
};
|
||||
|
||||
public:
|
||||
DisplayNames(Object& prototype);
|
||||
virtual ~DisplayNames() override = default;
|
||||
|
@ -55,11 +63,17 @@ public:
|
|||
void set_fallback(StringView fallback);
|
||||
StringView fallback_string() const;
|
||||
|
||||
bool has_language_display() const { return m_language_display.has_value(); }
|
||||
LanguageDisplay language_display() const { return *m_language_display; }
|
||||
void set_language_display(StringView language_display);
|
||||
StringView language_display_string() const;
|
||||
|
||||
private:
|
||||
String m_locale; // [[Locale]]
|
||||
Style m_style { Style::Invalid }; // [[Style]]
|
||||
Type m_type { Type::Invalid }; // [[Type]]
|
||||
Fallback m_fallback { Fallback::Invalid }; // [[Fallback]]
|
||||
String m_locale; // [[Locale]]
|
||||
Style m_style { Style::Invalid }; // [[Style]]
|
||||
Type m_type { Type::Invalid }; // [[Type]]
|
||||
Fallback m_fallback { Fallback::Invalid }; // [[Fallback]]
|
||||
Optional<LanguageDisplay> m_language_display {}; // [[LanguageDisplay]]
|
||||
};
|
||||
|
||||
ThrowCompletionOr<Value> canonical_code_for_display_names(GlobalObject& global_object, DisplayNames::Type type, StringView code);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue