1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 12:17:35 +00:00

LibJS: Implement a nearly empty Intl.DisplayNames object

This adds plumbing for the Intl.DisplayNames object, constructor, and
prototype.
This commit is contained in:
Timothy Flynn 2021-08-24 22:27:05 -04:00 committed by Linus Groh
parent 137e98cb6f
commit 0fb4e8b749
12 changed files with 325 additions and 1 deletions

View file

@ -0,0 +1,65 @@
/*
* Copyright (c) 2021, Tim Flynn <trflynn89@pm.me>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/String.h>
#include <AK/StringView.h>
#include <LibJS/Runtime/Object.h>
namespace JS::Intl {
class DisplayNames final : public Object {
JS_OBJECT(DisplayNames, Object);
enum class Style {
Invalid,
Narrow,
Short,
Long,
};
enum class Type {
Invalid,
Language,
Region,
Script,
Currency,
};
enum class Fallback {
Invalid,
None,
Code,
};
public:
DisplayNames(Object& prototype);
virtual ~DisplayNames() override = default;
String const& locale() const { return m_locale; }
void set_locale(String locale) { m_locale = move(locale); }
Style style() const { return m_style; }
void set_style(StringView style);
StringView style_string() const;
Type type() const { return m_type; }
void set_type(StringView type);
StringView type_string() const;
Fallback fallback() const { return m_fallback; }
void set_fallback(StringView fallback);
StringView fallback_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]]
};
}