Skip to content

Commit 866a71a

Browse files
authored
Include input & option descriptions as data in registry (#533)
* Actually include input & option descriptions as data in registry, not just comments * Use CLDR as currency code reference * Add xml:lang attributes to <registry>, <input> and <option> * Wrap all descriptions in <description> elements
1 parent 015c1d0 commit 866a71a

File tree

3 files changed

+228
-116
lines changed

3 files changed

+228
-116
lines changed

spec/registry.dtd

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
<!ELEMENT registry (function|validationRule)*>
2+
<!ATTLIST registry
3+
xml:lang NMTOKEN #IMPLIED
4+
>
25

3-
<!ELEMENT function (description,(formatSignature|matchSignature|alias)+)>
6+
<!ELEMENT function (description+,(formatSignature|matchSignature|alias)+)>
47
<!ATTLIST function
58
name NMTOKEN #REQUIRED
69
>
710

811
<!ELEMENT description (#PCDATA)>
12+
<!ATTLIST description
13+
xml:lang NMTOKEN #IMPLIED
14+
>
915

1016
<!ELEMENT validationRule EMPTY>
1117
<!ATTLIST validationRule
@@ -20,14 +26,14 @@
2026

2127
<!ELEMENT matchSignature (input?,option*,match*,override*)>
2228

23-
<!ELEMENT input EMPTY>
29+
<!ELEMENT input (description*)>
2430
<!ATTLIST input
2531
values NMTOKENS #IMPLIED
2632
validationRule IDREF #IMPLIED
2733
readonly (true|false) "false"
2834
>
2935

30-
<!ELEMENT option EMPTY>
36+
<!ELEMENT option (description*)>
3137
<!ATTLIST option
3238
name NMTOKEN #REQUIRED
3339
values NMTOKENS #IMPLIED

spec/registry.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The registry contains descriptions of function signatures.
3232

3333
The main building block of the registry is the `<function>` element.
3434
It represents an implementation of a custom function available to translation at runtime.
35-
A function defines a human-readable _description_ of its behavior
35+
A function defines a human-readable `<description>` of its behavior
3636
and one or more machine-readable _signatures_ of how to call it.
3737
Named `<validationRule>` elements can optionally define regex validation rules for
3838
literals, option values, and variant keys.
@@ -74,6 +74,11 @@ which provide shorthands for commonly used option baskets.
7474
An _alias name_ may be used equivalently to a _function name_ in messages.
7575
Its `<setOption>` values are always set, and may not be overridden in message annotations.
7676

77+
If a `<function>`, `<input>` or `<option>` includes multiple `<description>` elements,
78+
each SHOULD have a different `xml:lang` attribute value.
79+
This allows for the descriptions of these elements to be themselves localized
80+
according to the preferred locale of the message authors and editors.
81+
7782
## Example
7883

7984
The following `registry.xml` is an example of a registry file
@@ -84,7 +89,7 @@ For the sake of brevity, only `locales="en"` is considered.
8489
<?xml version="1.0" encoding="UTF-8" ?>
8590
<!DOCTYPE registry SYSTEM "./registry.dtd">
8691

87-
<registry>
92+
<registry xml:lang="en">
8893
<function name="platform">
8994
<description>Match the current OS.</description>
9095
<matchSignature>
@@ -165,7 +170,7 @@ A localization engineer can then extend the registry by defining the following `
165170
<?xml version="1.0" encoding="UTF-8" ?>
166171
<!DOCTYPE registry SYSTEM "./registry.dtd">
167172

168-
<registry>
173+
<registry xml:lang="en">
169174
<function name="noun">
170175
<description>Handle the grammar of a noun.</description>
171176
<formatSignature>

0 commit comments

Comments
 (0)