-
-
Notifications
You must be signed in to change notification settings - Fork 36
Add some capabilities for the builtin functions #457
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
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
6eba3ce
add some capabilities for the builtin functions
ryzokuken 92512a4
move exploration about builtins
ryzokuken 63cd2ca
apply suggestions
ryzokuken edcf004
add status to capabilities proposal
ryzokuken 1a009c4
manually run prettier on file
ryzokuken c33e026
style: Apply Prettier
github-actions[bot] e921309
Update exploration/0001-builtin-registry-capabilities.md
ryzokuken 0c26a64
add more details
ryzokuken 99ba72e
various improvements + apply suggestions
ryzokuken 4a52ec8
style: Apply Prettier
github-actions[bot] 62406f1
two more suggestions
ryzokuken 185707b
break lines and adopt some suggestions
ryzokuken 5881193
improve alternatives
ryzokuken 4ebad87
style: Apply Prettier
github-actions[bot] 96c8c43
apply more suggestions
ryzokuken File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 @@ | ||
# Capabilities for built-in registry | ||
|
||
Status: **Proposed** | ||
|
||
<details> | ||
<summary>Metadata</summary> | ||
<dl> | ||
<dt>Contributors</dt> | ||
<dd>@ryzokuken</dd> | ||
<dt>First proposed</dt> | ||
<dd>2023-08-22</dd> | ||
<dt>Pull Request</dt> | ||
<dd><a href="https://github.com/unicode-org/message-format-wg/pull/457">#457</a></dd> | ||
</dl> | ||
</details> | ||
|
||
## Objective | ||
|
||
Document the set of capabilities needed by the _built-in registry_ in order to provide a reasonably complete set of | ||
functions. | ||
This includes ensuring sufficient compatibility with the various functions available in ICU4X, JavaScript `Intl` as well | ||
as MessageFormat v1. | ||
|
||
## Background | ||
|
||
Users have the ability to specify and call arbitrary custom functions in their messages thanks to the function registry. | ||
That said, there are a number of common i18n operations that are quite universal and there's a lot of value in | ||
standardizing the usage of these common operations across the ecosystem. | ||
This document aims to list down the basic capabilities that implementations need to be provide in a _built-in registry_. | ||
|
||
## Use-Cases | ||
|
||
From formatting date and time values to performing selection based on plural rules, the use cases for a minimal set of | ||
common tools standardized across implementations are virtually everywhere. | ||
While a number of applications might require more complex functions with custom logic, a well-provisioned default | ||
registry could significantly lower the barrier of entry as well as the need to write and maintain many custom functions. | ||
|
||
## Requirements | ||
|
||
Implementations are required to implement and expose the entire _built-in registry_ that would provide the capabilities | ||
in this document. | ||
|
||
The names of functions and associated options defined by the registry **MUST** remain unchanged for the sake of | ||
compatibility, interoperability and general API stability. | ||
|
||
## Constraints | ||
|
||
Since MessageFormat would be used alongside other internationalization features in many programming environments, the | ||
final interface **SHOULD NOT** deviate a lot from existing APIs in order to minimize developer confusion. | ||
|
||
## Proposed Design | ||
|
||
The **_<dfn>built-in registry</dfn>_** is the set of functions, together with their options, that are present in every | ||
implementation. | ||
Implementations MUST provide each of the functions defined in the _built-in registry_, including all of the options. | ||
The output of each function is implementation-defined. | ||
Implementations MAY include additional options for built-in functions, although implementers are cautioned to avoid | ||
adding options that might conflict with future standardization. | ||
These include the following capabilities: | ||
|
||
- Formatting the following types of data in a locale-sensitive manner: | ||
- Dates and times | ||
- Numbers | ||
- Lists | ||
- Selecting between pattern strings in a locale-sensitive manner based on: | ||
- String equality | ||
- Plural rules | ||
- Ordinality | ||
|
||
## Alternatives Considered | ||
|
||
The working group has considered a number of ways to address core functionality. These include: | ||
|
||
**No default registry** Each implementation would be free to define its own set of functions and options for each. | ||
|
||
- (+) Each implementation would be able to define functions and options according to existing I18N APIs which would be | ||
familiar to users in that language or runtime | ||
- (-) Messages would not be portable between implementations | ||
- (-) Users would have to learn the variations between implementations | ||
- (-) Tooling would have to be adjusted for each variation | ||
|
||
**Informative registry** The default registry could be made informative with implementations allowed to pick-and-choose | ||
(or ignore) entries. | ||
This would provide better interoperability for implementations claiming to implement the default registry, while | ||
allowing platform-specific variation. | ||
|
||
**Non-extensible registry entries** Like this design, but not allowing implementation specific options. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.