diff --git a/fluent/CHANGELOG.md b/fluent/CHANGELOG.md index b690df796..75c8937a3 100644 --- a/fluent/CHANGELOG.md +++ b/fluent/CHANGELOG.md @@ -1,21 +1,87 @@ # Changelog -## Unreleased +## fluent 0.6.0 (January 31, 2018) - - Remove MessageContext.formatToParts. + - Implement Fluent Syntax 0.5. + + - Add support for terms. + - Add support for `#`, `##` and `###` comments. + - Remove support for tags. + - Add support for `=` after the identifier in message and term + defintions. + - Forbid newlines in string expressions. + - Allow trailing comma in call expression argument lists. + + In fluent 0.6.x the new Syntax 0.5 is supported alongside the old Syntax + 0.4. This should make migrations easier. The parser will correctly parse + Syntax 0.4 comments (prefixed with `//`), sections and message + definitions without the `=` after the identifier. The one exception are + tags which are no longer supported. Please use attributed defined on + terms instead. + + - Add `mapContextAsync`. (#125) + + This is the async counterpart to mapContextSync. Given an async iterable + of `MessageContext` instances and an array of ids (or a single id), it + maps each identifier to the first `MessageContext` which contains the + message for it. + + An ordered interable of `MessageContext` instances can represent the + current negotiated fallback chain of languages. This iterable can be used + to find the best existing translation for a given identifier. + + The iterable of `MessageContexts` can now be async, allowing code like + this: + + ```js + async formatString(id, args) { + const ctx = await mapContextAsync(contexts, id); + + if (ctx === null) { + return id; + } + + const msg = ctx.getMessage(id); + return ctx.format(msg, args); + } + ``` + + The iterable of `MessageContexts` should always be wrapped in + `CachedIterable` to optimize subsequent calls to `mapContextSync` and + `mapContextAsync`. + + Because `mapContextAsync` uses asynchronous iteration you'll likely need + the regenerator runtime provided by `babel-polyfill` to run the `compat` + builds of `fluent`. + + - Expose the `ftl` dedent helper. + + The `ftl` template literal tag can be used to conveniently include FTL + snippets in other code. It strips the common indentation from the snippet + allowing it to be indented on the level dictated by the current code + indentation. + + ```js + ctx.addMessages(ftl` + foo = Foo + bar = Bar + ); + ``` + + - Remove `MessageContext.formatToParts`. It's only use-case was passing React elements as arguments to translations which is now possible thanks to DOM overlays (#101). - - Rename FluentType.valueOf to FluentType.toString. + - Rename `FluentType.valueOf` to `FluentType.toString1. - Without MessageContext.formatToParts, all use-cases for - FluentType.valueOf boil down to stringification. + Without `MessageContext.formatToParts`, all use-cases for + `FluentType.valueOf` boil down to stringification. - - Remove FluentType.isTypeOf. + - Remove `FluentType.isTypeOf`. fluent-react's markup overlays (#101) removed the dependency on fluent's - FluentType which was hardcoded as an import from fluent/compat. Without + `FluentType` which was hardcoded as an import from fluent/compat. Without this dependency all imports from fluent are in the hands of developers again and they can decide to use the ES2015+ or the compat builds as they wish. As long as they do it consistently, regular instanceof checks will diff --git a/fluent/README.md b/fluent/README.md index eb9f6b699..d28391f9e 100644 --- a/fluent/README.md +++ b/fluent/README.md @@ -19,13 +19,13 @@ The `MessageContext` constructor provides the core functionality of formatting translations from FTL files. ```javascript -import { MessageContext } from 'fluent'; +import { MessageContext, ftl } from 'fluent'; const ctx = new MessageContext('en-US'); -const errors = ctx.addMessages(` -brand-name = Foo 3000 -welcome = Welcome, { $name }, to { brand-name }! +const errors = ctx.addMessages(ftl` + -brand-name = Foo 3000 + welcome = Welcome, { $name }, to { -brand-name }! `); if (errors.length) { @@ -59,7 +59,7 @@ import { MessageContext } from 'fluent'; ``` For legacy browsers, the `compat` build has been transpiled using Babel's [env -preset][]: +preset][]. It requires the regenerator runtime provided by [babel-polyfill][]. ```javascript import { MessageContext } from 'fluent/compat'; @@ -75,6 +75,7 @@ implementations, and information about how to get involved. [intl-pluralrules]: https://www.npmjs.com/package/intl-pluralrules [fluent-intl-polyfill]: https://www.npmjs.com/package/fluent-intl-polyfill +[babel-polyfill]: https://babeljs.io/docs/usage/polyfill/ [Stage 3 proposal]:https://github.com/tc39/proposal-intl-plural-rules [env preset]: https://babeljs.io/docs/plugins/preset-env/ [projectfluent.org]: http://projectfluent.org diff --git a/fluent/package.json b/fluent/package.json index 4d92762c0..06d6073ab 100644 --- a/fluent/package.json +++ b/fluent/package.json @@ -1,7 +1,7 @@ { "name": "fluent", "description": "Localization library for expressive translations.", - "version": "0.4.2", + "version": "0.6.0", "homepage": "http://projectfluent.org", "author": "Mozilla ", "license": "Apache-2.0",