8000 Define function aliases in registry, initially including `:integer` by eemeli · Pull Request #532 · unicode-org/message-format-wg · GitHub
[go: up one dir, main page]

Skip to content

Define function aliases in registry, initially including :integer #532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion spec/registry.dtd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!ELEMENT registry (function|validationRule)*>

<!ELEMENT function (description,(formatSignature|matchSignature)+)>
<!ELEMENT function (description,(formatSignature|matchSignature|alias)+)>
<!ATTLIST function
name NMTOKEN #REQUIRED
>
Expand Down Expand Up @@ -46,3 +46,15 @@
values NMTOKENS #IMPLIED
validationRule IDREF #IMPLIED
>

<!ELEMENT alias (description,setOption*)>
<!ATTLIST alias
name NMTOKEN #REQUIRED
supports (format|match|all) "all"
>

<!ELEMENT setOption EMPTY>
<!ATTLIST setOption
name NMTOKEN #REQUIRED
value CDATA #REQUIRED
>
11 changes: 11 additions & 0 deletions spec/registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ Read-only options (the `readonly` attribute) can be displayed to translators in
Matching-function signatures additionally include one or more `<match>` elements
to define the keys against which they can match when used as selectors.

Functions may also include `<alias>` definitions,
which provide shorthands for commonly used option baskets.
An _alias name_ may be used equivalently to a _function name_ in messages.
Its `<setOption>` values are always set, and may not be overridden in message annotations.

## Example

The following `registry.xml` is an example of a registry file
Expand Down Expand Up @@ -116,6 +121,12 @@ For the sake of brevity, only `locales="en"` is considered.
<option name="style" readonly="true" values="decimal currency percent unit" default="decimal"/>
<option name="currency" readonly="true" validationRule="currencyCode"/>
</formatSignature>

<alias name="integer">
<description>Locale-sensitive integral number formatting</description>
<setOption name="maximumFractionDigits" value="0" />
<setOption name="style" value="decimal" />
</alias>
</function>
</registry>
```
Expand Down
5 changes: 5 additions & 0 deletions spec/registry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@
<option name="maximumSignificantDigits" values="positiveInteger" default="21"/>
</formatSignature>

<alias name="integer">
<description>Locale-sensitive integral number formatting</description>
<setOption name="maximumFractionDigits" value="0" />
<setOption name="style" value="decimal" />
</alias>
</function>

</registry>
0