1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 13:55:06 +00:00
serenity/Userland/Libraries/LibUnicode
Timothy Flynn ea78bac36d LibUnicode: Parse and generate per-locale plural rules from the CLDR
Plural rules in the CLDR are of the form:

"cs": {
    "pluralRule-count-one": "i = 1 and v = 0 @integer 1",
    "pluralRule-count-few": "i = 2..4 and v = 0 @integer 2~4",
    "pluralRule-count-many": "v != 0 @decimal 0.0~1.5, 10.0, 100.0 ...",
    "pluralRule-count-other": "@integer 0, 5~19, 100, 1000, 10000 ..."
}

The syntax is described here:
https://unicode.org/reports/tr35/tr35-numbers.html#Plural_rules_syntax

There are up to 2 sets of rules for each locale, a cardinal set and an
ordinal set. The approach here is to generate a C++ function for each
set of rules. Each condition in the rules (e.g. "i = 1 and v = 0") is
transpiled to a C++ if-statement within its function. Then lookup tables
are generated to match locales to their generated functions.

NOTE: -Wno-parentheses-equality is added to the LibUnicodeData compile
flags because the generated plural rules have lots of extra parentheses
(because e.g. we need to selectively negate and combine rules). The code
to generate only exactly the right number of parentheses is quite hairy,
so this just tells the compiler to ignore the extras.
2022-07-08 11:51:54 +02:00
..
CharacterTypes.cpp Meta+LibUnicode: Download and parse Unicode block properties 2022-02-15 10:13:19 -05:00
CharacterTypes.h Meta+LibUnicode: Download and parse Unicode block properties 2022-02-15 10:13:19 -05:00
CMakeLists.txt LibUnicode: Parse and generate per-locale plural rules from the CLDR 2022-07-08 11:51:54 +02:00
CurrencyCode.cpp Everywhere: Update copyrights with my new serenityos.org e-mail :^) 2022-01-31 18:23:22 +00:00
CurrencyCode.h Everywhere: Update copyrights with my new serenityos.org e-mail :^) 2022-01-31 18:23:22 +00:00
DateTimeFormat.cpp LibUnicode: Generate per-region week data 2022-07-06 16:56:42 +02:00
DateTimeFormat.h LibUnicode: Generate per-region week data 2022-07-06 16:56:42 +02:00
Forward.h LibUnicode: Parse and generate per-locale plural rules from the CLDR 2022-07-08 11:51:54 +02:00
Locale.cpp LibUnicode: Generate per-locale text layout information 2022-07-06 16:56:42 +02:00
Locale.h LibUnicode: Generate per-locale text layout information 2022-07-06 16:56:42 +02:00
NumberFormat.cpp AK: Use an enum instead of a bool for String::replace(all_occurences) 2022-07-06 11:12:45 +02:00
NumberFormat.h LibUnicode: Extract the timeSeparator numeric symbol from CLDR 2022-07-01 01:00:05 +03:00
PluralRules.cpp LibUnicode: Parse and generate per-locale plural rules from the CLDR 2022-07-08 11:51:54 +02:00
PluralRules.h LibUnicode: Parse and generate per-locale plural rules from the CLDR 2022-07-08 11:51:54 +02:00
RelativeTimeFormat.cpp Everywhere: Update copyrights with my new serenityos.org e-mail :^) 2022-01-31 18:23:22 +00:00
RelativeTimeFormat.h Everywhere: Update copyrights with my new serenityos.org e-mail :^) 2022-01-31 18:23:22 +00:00