Skip to content

Commit

Permalink
Merge pull request tc39#2 from dminor/fix-style
Browse files Browse the repository at this point in the history
Fix README.md styling
  • Loading branch information
dminor committed Feb 4, 2022
2 parents 8332a30 + 324db0b commit 9c4454c
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 57 deletions.
126 changes: 70 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,102 +8,116 @@ Champions: Eemeli Aro (Mozilla), Daniel Minor (Mozilla)

## Motivation

Intl.MessageFormat will build upon the [MessageFormat 2.0](https://github.com/unicode-org/message-format-wg/) (hereafter MF2.0)
specification currently under development. It will allow the use of MF2.0 resources
to localize web sites, enabling localization of the web using industry standard tooling and
processes. This should in turn make it easier to localize the web, increasing the openness
and accessibility of the web for speakers of languages other than the handful of languages for
which localization is typically done.

It is likely that eventually browsers themselves will be localized using MF2.0. This is already
planned for Firefox. If this happens, it will make sense to expose the MF2.0 implementation
already present in the browser to the web, rather than relying upon userland libraries.
Intl.MessageFormat will build upon the
[MessageFormat 2.0](https://github.com/unicode-org/message-format-wg/) (hereafter MF2)
specification currently under development.
It will allow the use of MF2 resources to localize web sites,
enabling localization of the web using industry standard tooling and processes.
This should in turn make it easier to localize the web,
increasing the openness and accessibility of the web for speakers of languages
other than the handful of languages for which localization is typically done.

It is likely that eventually browsers themselves will be localized using MF2.
This is already planned for Firefox.
If this happens,
it will make sense to expose the MF2 implementation already present in the browser to the web,
rather than relying upon userland libraries.

## Use cases

* The primary use case is the retrieval of localized text ("a message") given a message
identifier and a previously specified locale.
- The primary use case is the retrieval of localized text ("a message")
given a message identifier and a previously specified locale.

## Description

### API

The MF2.0 specification is still being developed by the working group. The API below is based
upon one proposal under consideration, but should not be considered representative of a
consensus among the working group. In particular, the API shape of `MessageFormatOptions`,
`Message`, `Scope` and `ResolvedOptions` will depend upon the data model chosen by the
working group.
The MF2 specification is still being developed by the working group.
The API below is based upon one proposal under consideration,
but should not be considered representative of a consensus among the working group.
In particular, the API shape of
`MessageFormatOptions`, `Message`, `Scope` and `ResolvedOptions`
will depend upon the data model chosen by the working group.

The interface provided by `Message` will be defined by the MF2.0 data model developed by
the MF2.0 working group. It contains localized text for a particular locale.
The interface provided by `Message` will be defined by
the MF2 data model developed by the MF2 working group.
It contains localized text for a particular locale.

```
interface Message { }
```ts
interface Message {}
```

A `Resource` is a group of related messages for a single locale. Messages can be organized
in a flat structure, or in hierarchy, using paths. Conceptually, it is similar to a file
containing a set of messages, but there are no constrains implied on the underlying
implementation.
A `Resource` is a group of related messages for a single locale.
Messages can be organized in a flat structure, or in hierarchy, using paths.
Conceptually, it is similar to a file containing a set of messages,
but there are no constrains implied on the underlying implementation.

```
interface Resource {
getId(): string;
```ts
interface Resource {
getId(): string;

getMessage(path: string[]): Message | undefined;
}
getMessage(path: string[]): Message | undefined;
}
```

The `Intl.MessageFormat` constructor creates `MessageFormat` instances for a given locale,
`MessageFormatOptions` and an optional set of `Resource`s. The remaining operations are
defined on `MessageFormat` instances.

The interfaces for `MessageFormatOptions`, `Scope` and `ResolvedOptions` will be defined
by the MF2.0 data model. `MessageFormatOptions` contains configuration options for the
creation of `MessageFormat` instances. The `Scope` object is used to lookup variable
references used in the `Message`. The `ResolvedOptions` object contains the options
`MessageFormatOptions` and an optional set of `Resource`s.
The remaining operations are defined on `MessageFormat` instances.

The interfaces for
`MessageFormatOptions`, `Scope` and `ResolvedOptions`
will be defined by the MF2 data model.
`MessageFormatOptions` contains configuration options
for the creation of `MessageFormat` instances.
The `Scope` object is used to lookup variable references used in the `Message`.
The `ResolvedOptions` object contains the options
resolved during the construction of the `MessageFormat` instance.

```
interface MessageFormatOptions { }
```ts
interface MessageFormatOptions { }

interface Scope { }
interface Scope { }

Intl.MessageFormat(
interface Intl.MessageFormat {
new (
locales: string | string[],
options?: MessageFormatOptions | null,
...resources: Resource[]
) : MessageFormat;
MessageFormat.addResources(...resources: Resource[]);
): Intl.MessageFormat;

MessageFormat.format(msgPath: string | string[], scope?: Scope): string;
addResources(...resources: Resource[]);

MessageFormat.format(resId: string, msgPath: string | string[], scope?: Scope): string;
format(msgPath: string | string[], scope?: Scope): string;
format(resId: string, msgPath: string | string[], scope?: Scope): string;

MessageFormat.formatToParts(
formatToParts(
resId: string,
msgPath: string | string[],
scope?: Scope
): MessageFormatPart[];

MessageFormat.resolvedOptions() : ResolvedOptions;
resolvedOptions(): ResolvedOptions;
}
```

## Comparison

The MF2.0 specification is being developed based upon lessons learned from existing
systems including
[MessageFormat](https://unicode-org.github.io/icu/userguide/format_parse/messages/) and [Fluent](https://projectfluent.org/).
The MF2 specification is being developed based upon lessons learned from existing systems
including [ICU MessageFormat] and [Fluent].

The implementation of Fluent within Firefox mostly relies upon
a declarative syntax in the DOM,
but it does provide an [API] for retrieving messages directly from Fluent
when not being used to localize the DOM.

The implementation of Fluent within Firefox mostly relies upon a declarative syntax in the
DOM, but it does provide an [API](https://firefox-source-docs.mozilla.org/l10n/fluent/tutorial.html#non-markup-localization)
for retrieving messages directly from Fluent when not being used to localize the DOM.
[icu messageformat]: https://unicode-org.github.io/icu/userguide/format_parse/messages/
[fluent]: https://projectfluent.org/
[api]: https://firefox-source-docs.mozilla.org/l10n/fluent/tutorial.html#non-markup-localization

## Implementations

### Polyfill/transpiler implementations

The MessageFormat 2.0 specification is under development. An experimental implementation of one
proposal for the MessageFormat 2.0 specification is available at
The MessageFormat 2.0 specification is under development.
An experimental implementation of one proposal for the MessageFormat 2.0 specification is available at
[mf2](https://github.com/messageformat/messageformat/tree/mf2/packages/messageformat)
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2290,7 +2290,7 @@
.clause-attributes-tag a {
color: #884400;
}
</style></head><body><div id="menu-toggle">☰</div><div id="menu-spacer"></div><div id="menu"><div id="menu-search"><input type="text" id="menu-search-box" placeholder="Search..."><div id="menu-search-results" class="inactive"></div></div><div id="menu-pins"><div class="menu-pane-header">Pins</div><ul id="menu-pins-list"></ul></div><div class="menu-pane-header">Table of Contents</div><div id="menu-toc"><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-demo-clause" title="This is an emu-clause"><span class="secnum">1</span> This is an emu-clause</a></li><li><span class="item-toggle-none"></span><a href="#sec-copyright-and-software-license" title="Copyright &amp; Software License"><span class="secnum">A</span> Copyright &amp; Software License</a></li></ol></div></div><div id="spec-container"><h1 class="version">Stage -1 Draft / January 26, 2022</h1><h1 class="title">Proposal Title Goes Here</h1>
</style></head><body><div id="menu-toggle">☰</div><div id="menu-spacer"></div><div id="menu"><div id="menu-search"><input type="text" id="menu-search-box" placeholder="Search..."><div id="menu-search-results" class="inactive"></div></div><div id="menu-pins"><div class="menu-pane-header">Pins</div><ul id="menu-pins-list"></ul></div><div class="menu-pane-header">Table of Contents</div><div id="menu-toc"><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-demo-clause" title="This is an emu-clause"><span class="secnum">1</span> This is an emu-clause</a></li><li><span class="item-toggle-none"></span><a href="#sec-copyright-and-software-license" title="Copyright &amp; Software License"><span class="secnum">A</span> Copyright &amp; Software License</a></li></ol></div></div><div id="spec-container"><h1 class="version">Stage -1 Draft / February 4, 2022</h1><h1 class="title">Proposal Title Goes Here</h1>

<emu-clause id="sec-demo-clause">
<h1><span class="secnum">1</span> This is an emu-clause</h1>
Expand Down

0 comments on commit 9c4454c

Please sign in to comment.