rhoella 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +35 -46
- data/reference/ruby/rhoella/cldr.rb +26 -0
- data/reference/ruby/rhoella/number_profile.rb +20 -5
- data/reference/ruby/rhoella/version.rb +1 -1
- data/reference/ruby/rhoella.rb +14 -0
- metadata +6 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: be3da69222acf8a04fbb68517e4f2b61a5cd9e6677a96891cccc43c4902969b3
|
|
4
|
+
data.tar.gz: 6b56d26f94eaae96229c94815320d5ae19bde066b73f4088443c97f0ef4ff0cc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 597386782d1af2da2d4d13cd2ef274bb4780a9a33574fb880b4dfb57886700b40cbf15603ed3c63000a06da172d48bf31ba9e223490e24b15aa067939f7b4e25
|
|
7
|
+
data.tar.gz: 0eab299f8e7cff5615807a20e1ac98d56613645cde17136d288a18029ab88f42049fb5b270c94bc387da45fdbb5061e4b0a70bb232cc65c3ced2544bdbff1d47
|
data/README.md
CHANGED
|
@@ -134,56 +134,45 @@ else, never silently wrong.
|
|
|
134
134
|
message references, bare term references and string literals, per
|
|
135
135
|
the fluent-rs rule
|
|
136
136
|
|
|
137
|
-
## The number
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
- **the profile shape** (docs/number-profiles/SPEC.md): a profile is a
|
|
145
|
-
sealed YAML document over one flat typed vocabulary — `decimal`,
|
|
146
|
-
`grouping` (per-side `separator`/`size`/`hanging: isolate|fold`),
|
|
147
|
-
`rounding` (strategy × tie), `precision` (exact / significant /
|
|
148
|
-
fractional / total), `notation` (basic | e | scientific |
|
|
149
|
-
engineering, with threshold `flip`), `exponent` (glyph/times/sign),
|
|
150
|
-
`signs`, `leading_zero`, `radix` (base/case/prefix/postfix) — plus
|
|
151
|
-
`formats`, the profile's named per-purpose delta-sets. Every field
|
|
152
|
-
explicit; no engine defaults.
|
|
153
|
-
- **one merge algebra, three axes**: `⊕` is a deep per-node merge with
|
|
154
|
-
nil-cancellation, applied as (1) inheritance — `inherits:` with
|
|
155
|
-
pinned parents, composed at load; (2) specialization — `formats`,
|
|
156
|
-
addressable `(profile, format)`, `extends` composing delta-sets;
|
|
157
|
-
(3) localization — language-keyed symbol maps resolved by document
|
|
158
|
-
language. `base` owns the structure keys; the `languages/*.yml`
|
|
159
|
-
totals own the symbol keys — disjoint, so composition cannot cancel
|
|
160
|
-
accidentally.
|
|
161
|
-
- **the audited authorities ship as fixtures** and as the seeds of the
|
|
162
|
-
rhoella-dictionaries package: `iso-80000-1` (comma in every language
|
|
163
|
-
version, ISO/IEC Directives Part 2 §9.1), `si-brochure` (BIPM 5.4.4,
|
|
164
|
-
language-keyed decimal, folded hanging digit), `itu` (apostrophe
|
|
165
|
-
groups), `iso-2533` (the TC 20/SC 6 document family with its named
|
|
166
|
-
formats — the PROFILE + FORMATS pattern)
|
|
167
|
-
- **the interpreter** (fixed semantics, profile-driven): parse →
|
|
168
|
-
flip-select on the original value → one-step round/pad (BigDecimal
|
|
169
|
-
arithmetic; away/even ties) → notation composition → signs →
|
|
170
|
-
grouping → radix affixes. Loud `ProfileError` on unknown profiles,
|
|
171
|
-
formats, languages and unknown profile keys — never silently
|
|
172
|
-
defaulted.
|
|
137
|
+
## The number config (the one number surface the engine keeps)
|
|
138
|
+
|
|
139
|
+
Numbers **render in plurimath** — the STEM algorithm (radix conversion,
|
|
140
|
+
hex capitalization, padding, digit budgets, notation coefficients) is
|
|
141
|
+
plurimath's, and so are the publication conventions (ISO 80000-1, ITU,
|
|
142
|
+
SI Brochure) as plurimath data. rhoella owns the **l10n number config**:
|
|
143
|
+
what CLDR says about a locale, handed to the renderer.
|
|
173
144
|
|
|
174
145
|
```ruby
|
|
175
|
-
Rhoella.
|
|
176
|
-
#=> "
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
146
|
+
Rhoella.number_format("hi")
|
|
147
|
+
#=> { "cldr_release" => "49.0.0", "locale" => "hi",
|
|
148
|
+
# "default_numbering_system" => "latn",
|
|
149
|
+
# "symbols" => { "decimal" => ".", "group" => ",", "plusSign" => "+",
|
|
150
|
+
# "minusSign" => "-", "percentSign" => "%" },
|
|
151
|
+
# "minimum_grouping_digits" => 1,
|
|
152
|
+
# "patterns" => { "decimal" => "#,##,##0.###" },
|
|
153
|
+
# "grouping" => { "primary" => 3, "secondary" => 2 } }
|
|
154
|
+
|
|
155
|
+
Rhoella.number_symbols("de")
|
|
156
|
+
#=> the raw sealed record: the symbols, "minimum_grouping_digits" ("1"),
|
|
157
|
+
# "decimal_pattern" ("#,##0.###") — unchanged (rhoella#25)
|
|
181
158
|
```
|
|
182
159
|
|
|
183
|
-
|
|
184
|
-
the `
|
|
185
|
-
|
|
186
|
-
|
|
160
|
+
`grouping` is read off the decimal pattern — `primary` is the rightmost
|
|
161
|
+
group, `secondary` the fixed size before it (`hi`/`en-IN` 3 / 2; `null`
|
|
162
|
+
everywhere else) — and `minimum_grouping_digits` is the CLDR rule that
|
|
163
|
+
keeps four-digit numbers ungrouped in `es`/`it`/`pl`/… (2). Locales the
|
|
164
|
+
package lacks resolve to `nil` through the subtag ladder, like every
|
|
165
|
+
other locale function; the data is the optional `rhoella-cldr` gem.
|
|
166
|
+
|
|
167
|
+
### Deprecated: the number-profile renderer (rhoella#36)
|
|
168
|
+
|
|
169
|
+
`Rhoella.render_number`, `Rhoella::Profiles` (`resolve`, `data_path=`,
|
|
170
|
+
`data_dir`) and the napi/Python equivalents are **deprecated and removed
|
|
171
|
+
in a later release**: they implement a second number renderer that has no
|
|
172
|
+
customer — the publication conventions they carried live in plurimath
|
|
173
|
+
now (plurimath#657) and the `rhoella-dictionaries` package is deprecated.
|
|
174
|
+
Every entry point warns; docs/number-profiles/SPEC.md stays for the
|
|
175
|
+
deprecation cycle only.
|
|
187
176
|
|
|
188
177
|
## Fluent semantics preserved
|
|
189
178
|
|
|
@@ -93,6 +93,32 @@ module Rhoella
|
|
|
93
93
|
table[resolve(locale, table.keys)]
|
|
94
94
|
end
|
|
95
95
|
|
|
96
|
+
# The number config for a locale (rhoella#35 — the one number
|
|
97
|
+
# surface the engine keeps; numbers render in plurimath): the
|
|
98
|
+
# record above with the decimal pattern under "patterns" and the
|
|
99
|
+
# grouping sizes read off it — primary is the rightmost group,
|
|
100
|
+
# secondary the one before it when it is a fixed size
|
|
101
|
+
# ("#,##,##0.###" → 3 / 2; "#,##0.###" → 3 / nil) — and
|
|
102
|
+
# minimumGroupingDigits as an Integer. nil for locales the
|
|
103
|
+
# package lacks.
|
|
104
|
+
def number_format(locale)
|
|
105
|
+
record = number_symbols(locale)
|
|
106
|
+
return unless record
|
|
107
|
+
|
|
108
|
+
pattern = record["decimal_pattern"]
|
|
109
|
+
record.reject { |key, _| key == "decimal_pattern" }.merge(
|
|
110
|
+
"minimum_grouping_digits" => record["minimum_grouping_digits"].to_i,
|
|
111
|
+
"patterns" => { "decimal" => pattern },
|
|
112
|
+
"grouping" => grouping_sizes(pattern),
|
|
113
|
+
)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
private def grouping_sizes(pattern)
|
|
117
|
+
runs = pattern.to_s.split(".").first.to_s.split(",").map { |run| run.count("#0") }
|
|
118
|
+
secondary = runs.length > 1 && runs[-2] > 1 ? runs[-2] : nil
|
|
119
|
+
{ "primary" => runs.last, "secondary" => secondary }
|
|
120
|
+
end
|
|
121
|
+
|
|
96
122
|
# Join already-localized items with the locale's listPattern
|
|
97
123
|
# (start/middle/end/"2" composition). Locales or types the package
|
|
98
124
|
# lacks fall back to the bare ", " join — the same fallback law as
|
|
@@ -38,11 +38,17 @@ module Rhoella
|
|
|
38
38
|
TIE_MODES = { "away" => BigDecimal::ROUND_HALF_UP,
|
|
39
39
|
"even" => BigDecimal::ROUND_HALF_EVEN }.freeze
|
|
40
40
|
|
|
41
|
+
# rhoella#36: number rendering lives in plurimath — the engine keeps
|
|
42
|
+
# the CLDR number config (Rhoella.number_format). This module and
|
|
43
|
+
# Rhoella.render_number are deprecated and removed in a later release.
|
|
44
|
+
DEPRECATION_NOTICE = "rhoella: %s is deprecated (rhoella#36) — numbers " \
|
|
45
|
+
"render in plurimath; rhoella keeps the CLDR number config " \
|
|
46
|
+
"(Rhoella.number_format). It will be removed in a later release.".freeze
|
|
47
|
+
|
|
41
48
|
class << self
|
|
42
49
|
# The native core seam (rhoella#31): when the magnus extension is
|
|
43
50
|
# built and required, render_number routes to the Rust engine —
|
|
44
|
-
# byte-identity by construction.
|
|
45
|
-
# until the binding passes the full suite (the migration law).
|
|
51
|
+
# byte-identity by construction.
|
|
46
52
|
def native!
|
|
47
53
|
require "rhoella_native_ext"
|
|
48
54
|
@native = RhoellaNative::Profiles
|
|
@@ -54,6 +60,7 @@ module Rhoella
|
|
|
54
60
|
end
|
|
55
61
|
|
|
56
62
|
def data_path=(path)
|
|
63
|
+
warn DEPRECATION_NOTICE % "Rhoella::Profiles.data_path="
|
|
57
64
|
@data_path = path
|
|
58
65
|
reset!
|
|
59
66
|
@native&.set_profiles_data_dir(File.expand_path(path))
|
|
@@ -65,11 +72,17 @@ module Rhoella
|
|
|
65
72
|
nil
|
|
66
73
|
end
|
|
67
74
|
|
|
68
|
-
#
|
|
75
|
+
# Deprecated (rhoella#36): the resolved rules for a profile/format/
|
|
76
|
+
# language combination.
|
|
77
|
+
def resolve(profile: "base", format: nil, lang: "en", delta: nil)
|
|
78
|
+
warn DEPRECATION_NOTICE % "Rhoella::Profiles.resolve"
|
|
79
|
+
resolve_rules(profile: profile, format: format, lang: lang, delta: delta)
|
|
80
|
+
end
|
|
81
|
+
|
|
69
82
|
# Chain (SPEC §2): base ⊕ language ⊕ authority ⊕ format. Raises
|
|
70
83
|
# ProfileError for unknown profiles/formats/languages and for
|
|
71
84
|
# totality violations.
|
|
72
|
-
def
|
|
85
|
+
private def resolve_rules(profile: "base", format: nil, lang: "en", delta: nil)
|
|
73
86
|
resolved = merge(merge(base_rules, language_rules(lang)),
|
|
74
87
|
authority_rules(profile))
|
|
75
88
|
resolved = merge(resolved, format_rules(profile, format)) if format
|
|
@@ -87,7 +100,9 @@ module Rhoella
|
|
|
87
100
|
|
|
88
101
|
# The interpreter (SPEC §4): parse → flip-select (original value)
|
|
89
102
|
# → round/pad → compose → signs → grouping → affixes.
|
|
103
|
+
# Deprecated (rhoella#36).
|
|
90
104
|
def render(value_text, profile: "base", format: nil, lang: "en", delta: nil)
|
|
105
|
+
warn DEPRECATION_NOTICE % "Rhoella.render_number / Rhoella::Profiles.render"
|
|
91
106
|
if native?
|
|
92
107
|
begin
|
|
93
108
|
return delta ?
|
|
@@ -104,7 +119,7 @@ module Rhoella
|
|
|
104
119
|
end
|
|
105
120
|
end
|
|
106
121
|
|
|
107
|
-
rules =
|
|
122
|
+
rules = resolve_rules(profile: profile, format: format, lang: lang, delta: delta)
|
|
108
123
|
original = value_text.to_s.strip
|
|
109
124
|
value = BigDecimal(original)
|
|
110
125
|
mag = value.abs
|
data/reference/ruby/rhoella.rb
CHANGED
|
@@ -231,6 +231,20 @@ module Rhoella
|
|
|
231
231
|
Cldr.number_symbols(locale)
|
|
232
232
|
end
|
|
233
233
|
|
|
234
|
+
# The number config for a locale (rhoella#35): the symbol record
|
|
235
|
+
# plus "patterns" (the decimal pattern) and "grouping" (primary /
|
|
236
|
+
# secondary sizes read off it) with minimumGroupingDigits as an
|
|
237
|
+
# Integer — the l10n config the number renderer (plurimath)
|
|
238
|
+
# consumes. nil for locales the package lacks; CldrError when no
|
|
239
|
+
# package is installed.
|
|
240
|
+
def self.number_format(locale)
|
|
241
|
+
Cldr.number_format(locale)
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
# DEPRECATED (rhoella#36 — removal in a later release): number
|
|
245
|
+
# rendering lives in plurimath; the engine keeps the CLDR number
|
|
246
|
+
# config (Rhoella.number_format). Kept for one release cycle.
|
|
247
|
+
#
|
|
234
248
|
# Render a number under a number profile (docs/number-profiles/
|
|
235
249
|
# SPEC.md — the audited metanorma vocabulary as declarative YAML):
|
|
236
250
|
# render_number("60007.12345", profile: "iso-80000-1") →
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rhoella
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Metanorma
|
|
@@ -28,12 +28,10 @@ description: 'Rhoella — from the Greek rhoia, the flow — the localization en
|
|
|
28
28
|
normative publishing: a Fluent (FTL) engine (messages, placeables, a function registry,
|
|
29
29
|
isolation, bounded resolution) plus the sealed locale layer for standards rendering
|
|
30
30
|
— CLDR spellout/ordinals/calendar symbols/list patterns/plural categories via the
|
|
31
|
-
optional rhoella-cldr gem, and the number
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
is the OPTIONAL rhoella-cldr / rhoella-dictionaries gems, resolved by explicit path,
|
|
36
|
-
installed gem, or environment.'
|
|
31
|
+
optional rhoella-cldr gem, and the CLDR number config (Rhoella.number_format: symbols,
|
|
32
|
+
patterns, grouping sizes, minimumGroupingDigits) handed to the number renderer,
|
|
33
|
+
plurimath. Ships CODE only: data is the OPTIONAL rhoella-cldr gem, resolved by explicit
|
|
34
|
+
path, installed gem, or environment.'
|
|
37
35
|
email:
|
|
38
36
|
- open.source@ribose.com
|
|
39
37
|
executables: []
|
|
@@ -71,5 +69,5 @@ rubygems_version: 3.5.22
|
|
|
71
69
|
signing_key:
|
|
72
70
|
specification_version: 4
|
|
73
71
|
summary: 'Rhoella: the localization engine for normative publishing (Fluent + sealed
|
|
74
|
-
locale data + number
|
|
72
|
+
locale data + the CLDR number config)'
|
|
75
73
|
test_files: []
|