-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Move spec/registry.md -> spec/registry/default.md * Add Unicode Registry definition * Refer to BCP47, add note about only requiring normal tags * Call it a namespace * Apply suggestions from code review Co-authored-by: Addison Phillips <[email protected]> * Fix test file reference Co-authored-by: Tim Chevalier <[email protected]> * Apply suggestions from code review * Update spec/u-namespace.md Co-authored-by: Eemeli Aro <[email protected]> * Apply suggestions from code review Co-authored-by: Addison Phillips <[email protected]> * Apply suggestions from code review Co-authored-by: Addison Phillips <[email protected]> * Add mention of functions to namespace description --------- Co-authored-by: Addison Phillips <[email protected]> Co-authored-by: Tim Chevalier <[email protected]>
- Loading branch information
1 parent
efde4ff
commit 7f9a4de
Showing
6 changed files
with
240 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# MessageFormat 2.0 Unicode Namespace | ||
|
||
The `u:` _namespace_ is reserved for the definition of _options_ | ||
which affect the _function context_ of the specific _expressions_ | ||
in which they appear, | ||
or for the definition of _options_ that are universally applicable | ||
rather than function-specific. | ||
It might also be used to define _functions_ in a future release. | ||
|
||
The CLDR Technical Committee of the Unicode Consortium | ||
manages the specification for this namespace, hence the name `u:`. | ||
|
||
## Options | ||
|
||
This section describes common **_<dfn>`u:` options</dfn>_** which each implementation SHOULD support | ||
for all _functions_ and _markup_. | ||
|
||
### `u:id` | ||
|
||
A string value that is included as an `id` or other suitable value | ||
in the formatted parts for the _placeholder_, | ||
or any other structured formatted results. | ||
|
||
Ignored when formatting a message to a string. | ||
|
||
The value of the `u:id` _option_ MUST be a _literal_ or a | ||
_variable_ whose _resolved value_ is either a string | ||
or can be resolved to a string without error. | ||
For other values, a _Bad Option_ error is emitted | ||
and the `u:id` option is ignored. | ||
|
||
### `u:locale` | ||
|
||
Replaces the _locale_ defined in the _function context_ for this _expression_. | ||
|
||
A comma-delimited list consisting of | ||
well-formed [BCP 47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) | ||
language tags, | ||
or an implementation-defined list of such tags. | ||
|
||
If this option is set on _markup_, a _Bad Option_ error is emitted | ||
and the value of the `u:locale` option is ignored. | ||
|
||
During processing, the `u:locale` option | ||
MUST be removed from the resolved mapping of _options_ | ||
before calling the _function handler_. | ||
|
||
Values matching the following ABNF are always accepted: | ||
```abnf | ||
u-locale-option = unicode_bcp47_locale_id *(o "," o unicode_bcp47_locale_id) | ||
``` | ||
using `unicode_bcp47_locale_id` as defined for | ||
[Unicode Locale Identifier](https://cldr-smoke.unicode.org/spec/main/ldml/tr35.html#unicode_bcp47_locale_id). | ||
|
||
Implementations MAY support additional language tags, | ||
such as private-use or grandfathered tags, | ||
or tags using `_` instead of `-` as a separator. | ||
When the value of `u:locale` is set by a _variable_, | ||
implementations MAY support non-string values otherwise representing locales. | ||
|
||
Implementations MAY emit a _Bad Option_ error | ||
and MAY ignore the value of the `u:locale` _option_ as a whole | ||
or any of the entries in the list of language tags. | ||
This might be because the locale specified is not supported | ||
or because the language tag is not well-formed, | ||
not valid, or some other reason. | ||
|
||
### `u:dir` | ||
|
||
Replaces the base directionality defined in | ||
the _function context_ for this _expression_. | ||
|
||
If this option is set on _markup_, a _Bad Option_ error is emitted | ||
and the value of the `u:dir` option is ignored. | ||
|
||
During processing, the `u:dir` option | ||
MUST be removed from the resolved mapping of _options_ | ||
before calling the _function handler_. | ||
|
||
The value of the `u:dir` _option_ MUST be one of the following _literal_ values | ||
or a _variable_ whose _resolved value_ is one of these _literals_: | ||
- `ltr`: left-to-right directionality | ||
- `rtl`: right-to-left directionality | ||
- `auto`: directionality determined from _expression_ contents | ||
|
||
For other values, a _Bad Option_ error is emitted | ||
and the value of the `u:dir` option is ignored. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -269,6 +269,9 @@ | |
"name": { | ||
"type": "string" | ||
}, | ||
"id": { | ||
"type": "string" | ||
}, | ||
"options": { | ||
"type": "object" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/unicode-org/message-format-wg/main/test/schemas/v0/tests.schema.json", | ||
"scenario": "u: Options", | ||
"description": "Common options affecting the function context", | ||
"defaultTestProperties": { | ||
"locale": "en-US" | ||
}, | ||
"tests": [ | ||
{ | ||
"src": "{#tag u:id=x}content{/ns:tag u:id=x}", | ||
"exp": "content", | ||
"expParts": [ | ||
{ | ||
"type": "markup", | ||
"kind": "open", | ||
"id": "x", | ||
"name": "tag" | ||
}, | ||
{ | ||
"type": "literal", | ||
"value": "content" | ||
}, | ||
{ | ||
"type": "markup", | ||
"kind": "close", | ||
"id": "x", | ||
"name": "tag" | ||
} | ||
] | ||
}, | ||
{ | ||
"src": "{#tag u:dir=rtl u:locale=ar}content{/ns:tag}", | ||
"exp": "content", | ||
"expErrors": [{ "type": "bad-option" }, { "type": "bad-option" }], | ||
"expParts": [ | ||
{ | ||
"type": "markup", | ||
"kind": "open", | ||
"name": "tag" | ||
}, | ||
{ | ||
"type": "literal", | ||
"value": "content" | ||
}, | ||
{ | ||
"type": "markup", | ||
"kind": "close", | ||
"name": "tag" | ||
} | ||
] | ||
}, | ||
{ | ||
"src": "hello {4.2 :number u:locale=fr}", | ||
"exp": "hello 4,2" | ||
}, | ||
{ | ||
"src": "hello {world :string u:dir=ltr u:id=foo}", | ||
"exp": "hello world", | ||
"expParts": [ | ||
{ | ||
"type": "literal", | ||
"value": "hello " | ||
}, | ||
{ | ||
"type": "string", | ||
"source": "|world|", | ||
"dir": "ltr", | ||
"id": "foo", | ||
"value": "world" | ||
} | ||
] | ||
}, | ||
{ | ||
"src": "hello {world :string u:dir=rtl}", | ||
"exp": "hello \u2067world\u2069", | ||
"expParts": [ | ||
{ | ||
"type": "literal", | ||
"value": "hello " | ||
}, | ||
{ | ||
"type": "string", | ||
"source": "|world|", | ||
"dir": "rtl", | ||
"value": "world" | ||
} | ||
] | ||
}, | ||
{ | ||
"src": "hello {world :string u:dir=auto}", | ||
"exp": "hello \u2068world\u2069", | ||
"expParts": [ | ||
{ | ||
"type": "literal", | ||
"value": "hello " | ||
}, | ||
{ | ||
"type": "string", | ||
"source": "|world|", | ||
"dir": "auto", | ||
"value": "world" | ||
} | ||
] | ||
}, | ||
{ | ||
"locale": "ar", | ||
"src": "أهلاً {بالعالم :string u:dir=rtl}", | ||
"exp": "أهلاً \u2067بالعالم\u2069" | ||
}, | ||
{ | ||
"locale": "ar", | ||
"src": "أهلاً {بالعالم :string u:dir=auto}", | ||
"exp": "أهلاً \u2068بالعالم\u2069" | ||
}, | ||
{ | ||
"locale": "ar", | ||
"src": "أهلاً {world :string u:dir=ltr}", | ||
"exp": "أهلاً \u2066world\u2069" | ||
}, | ||
{ | ||
"locale": "ar", | ||
"src": "أهلاً {بالعالم :string}", | ||
"exp": "أهلاً \u2067بالعالم\u2069" | ||
} | ||
] | ||
} |