mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-01 12:07:14 +02: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:
committed by
Linus Groh
parent
137e98cb6f
commit
0fb4e8b749
Notes:
sideshowbarker
2024-07-18 05:15:39 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/0fb4e8b749d Pull-request: https://github.com/SerenityOS/serenity/pull/9599 Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/davidot Reviewed-by: https://github.com/linusg ✅
65
Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.h
Normal file
65
Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.h
Normal 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]]
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user