mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:47:35 +00:00
LibJS: Start implementing Intl.Segmenter
This commit is contained in:
parent
88c5992e0b
commit
a3bc06bb23
13 changed files with 334 additions and 9 deletions
39
Userland/Libraries/LibJS/Runtime/Intl/Segmenter.h
Normal file
39
Userland/Libraries/LibJS/Runtime/Intl/Segmenter.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Idan Horowitz <idan.horowitz@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
|
||||
namespace JS::Intl {
|
||||
|
||||
class Segmenter final : public Object {
|
||||
JS_OBJECT(Segmenter, Object);
|
||||
|
||||
public:
|
||||
enum class SegmenterGranularity {
|
||||
Grapheme,
|
||||
Word,
|
||||
Sentence,
|
||||
};
|
||||
|
||||
explicit Segmenter(Object& prototype);
|
||||
virtual ~Segmenter() override = default;
|
||||
|
||||
String const& locale() const { return m_locale; }
|
||||
void set_locale(String locale) { m_locale = move(locale); }
|
||||
|
||||
SegmenterGranularity segmenter_granularity() const { return m_segmenter_granularity; }
|
||||
void set_segmenter_granularity(StringView);
|
||||
StringView segmenter_granularity_string() const;
|
||||
|
||||
private:
|
||||
String m_locale; // [[Locale]]
|
||||
SegmenterGranularity m_segmenter_granularity { SegmenterGranularity::Grapheme }; // [[SegmenterGranularity]]
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue