mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
LibUnicode+Everywhere: Merge LibLocale back into LibUnicode
LibLocale was split off from LibUnicode a couple years ago to reduce the number of applications on SerenityOS that depend on CLDR data. Now that we use ICU, both LibUnicode and LibLocale are actually linking in this data. And since vcpkg gives us static libraries, both libraries are over 30MB in size. This patch reverts the separation and merges LibLocale into LibUnicode again. We now have just one library that includes the ICU data. Further, this will let LibUnicode share the locale cache that previously would only exist in LibLocale.
This commit is contained in:
parent
c9d9e1bb1f
commit
ebdb92eef6
Notes:
sideshowbarker
2024-07-16 16:23:32 +09:00
Author: https://github.com/trflynn89
Commit: ebdb92eef6
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/257
102 changed files with 675 additions and 711 deletions
57
Userland/Libraries/LibUnicode/RelativeTimeFormat.h
Normal file
57
Userland/Libraries/LibUnicode/RelativeTimeFormat.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright (c) 2022-2024, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibUnicode/Forward.h>
|
||||
|
||||
namespace Unicode {
|
||||
|
||||
// These are just the subset of fields in the CLDR required for ECMA-402.
|
||||
enum class TimeUnit {
|
||||
Second,
|
||||
Minute,
|
||||
Hour,
|
||||
Day,
|
||||
Week,
|
||||
Month,
|
||||
Quarter,
|
||||
Year,
|
||||
};
|
||||
Optional<TimeUnit> time_unit_from_string(StringView);
|
||||
StringView time_unit_to_string(TimeUnit);
|
||||
|
||||
enum class NumericDisplay {
|
||||
Always,
|
||||
Auto,
|
||||
};
|
||||
NumericDisplay numeric_display_from_string(StringView);
|
||||
StringView numeric_display_to_string(NumericDisplay);
|
||||
|
||||
class RelativeTimeFormat {
|
||||
public:
|
||||
static NonnullOwnPtr<RelativeTimeFormat> create(StringView locale, Style style);
|
||||
virtual ~RelativeTimeFormat() = default;
|
||||
|
||||
struct Partition {
|
||||
StringView type;
|
||||
String value;
|
||||
StringView unit;
|
||||
};
|
||||
|
||||
virtual String format(double, TimeUnit, NumericDisplay) const = 0;
|
||||
virtual Vector<Partition> format_to_parts(double, TimeUnit, NumericDisplay) const = 0;
|
||||
|
||||
protected:
|
||||
RelativeTimeFormat() = default;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue