Skip to content

Releases: projectfluent/fluent.js

@fluent/bundle 0.15.0

23 Jan 11:03
Compare
Choose a tag to compare
@fluent/bundle 0.15.0 Pre-release
Pre-release
  • Migrate to TypeScript. (#436)

    The source code of @fluent/bundle has been ported to TypeScript. There
    are no breaking changes to the public API.

    A new export has been added for TS consumers: FluentValue which is a
    union of the FluentType class and string. This reflects the
    implementation detail of @fluent/bundle which treats primitive strings
    as valid FluentType instances.

    The ES module files are now published into the esm directory. It also
    contains the type definitions for TS consumers. The src directory has
    been removed from the published packages.

@fluent/bundle 0.14.1

20 Dec 12:36
Compare
Choose a tag to compare
@fluent/bundle 0.14.1 Pre-release
Pre-release
  • Fix a big which made placeables which resolved to long strings format as {???}. (#439)

    Expressions which resolved to strings over 2500 characters long used to be
    considered dangerous. This is no longer the case. Instead, there's a limit
    on how many placeable can be resolved during a single call to
    formatPattern, to protect from high CPU usage in deeply nested patterns.

  • Fix a bug which made it impossible to pass a variable called hasOwnProperty to formatPattern. (#428)

@fluent/dom 0.6.0

21 Aug 19:13
Compare
Choose a tag to compare
@fluent/dom 0.6.0 Pre-release
Pre-release
  • Update @fluent/dom to work with @fluent/bundle 0.14

@fluent/react 0.10.0

30 Jul 12:15
Compare
Choose a tag to compare
@fluent/react 0.10.0 Pre-release
Pre-release
  • Update to @fluent/bundle 0.14.0.

    This version of @fluent/react can be used with the new FluentBundle
    API released in @fluent/bundle 0.14.0.

  • Report formatting errors from Localized and getString. (#412)

    Formatting errors are now printed to the console. In the future,
    @fluent/react will allow finer-grained control over rpeorting errors.
    See #411.

@fluent/bundle 0.14.0

30 Jul 11:43
Compare
Choose a tag to compare
@fluent/bundle 0.14.0 Pre-release
Pre-release

FluentBundle API

  • Remove FluentBundle.addMessages.

    Use FluentBundle.addResource instead, combined with a FluentResource
    instance.

  • Remove FluentBundle.messages.

    The list of messages in the bundle should not be inspected. If you need
    to do it, please use the tooling parser from @fluent/syntax.

  • Change the shape returned by FluentBundle.getMessage.

    The method now returns the following shape:

    {value: Pattern | null, attributes: Record<string, Pattern>}
    
  • The internal representtion of Pattern is private.

    Raw messages returned from getMessage have their values and attributes
    stored in a Pattern type. The internal representation of this type is
    private and implementation-specific. It should not be inspected nor used
    for any purposes. The implementation may change without a warning in
    future releases. Patterns are black boxes and are meant to be used as
    arguments to formatPattern.

  • Rename FluentBundle.format to formatPattern.

    formatPattern only accepts valid Patterns as the first argument. In
    practice, you'll want to first retrieve a raw message from the bundle via
    getMessage, and then format the value (if present) and the attributes
    separately.

    let message = bundle.getMessage("hello");
    if (message.value) {
        bundle.formatPattern(message.value, {userName: "Alex"});
    }

    The list of all attributes defined in the message can be obtained with
    Object.keys(message.attributes).

  • Throw from formatPattern when errors are not passed as an argument.

    The old format() method would silence all errors if the thrid argument,
    the errors array was not given. formatPattern changes this behavior
    to throwing on the first encountered error and interrupting the
    formatting.

    try {
        bundle.formatPattern(message.value, args);
    } catch (err) {
        // Handle the error yourself.
    }

    It's still possible to pass the errors array as the third argument to
    formatPattern. All errors encountered during the formatting will be
    then appended to the array. In this scenario, formatPattern is
    guaranteed to never throw because of errors in the translation.

    let errorrs = [];
    bundle.formatPattern(message.value, args, errors);
    for (let error of errors) {
        // Report errors.
    }

FluentResource API

  • Remove the static FluentResource.fromString method.

    Parse resources by using the constructor: new FluentResource(text).

  • Do not extend Map.

    FluentResources are now instances of their own class only.

  • Add FluentResource.body.

    The body field is an array storing the resource's parsed messages and
    terms.

FluentType API

  • FluentNumber must be instantiated with a number.

    The constructor doesn't call parseFloat on the passed value anymore.

  • FluentDateTime must be instantiated with a number.

    The constructor doesn't call new Date() on the passed value anymore.
    The date is stored as the numerical timestamp, in milliseconds since the
    epoch.

Formatting Changes

  • Report errors from instantiating Intl objects used for formatting.
  • Report errors from functions, including built-in functions.
  • Format numbers and dates to safe defaults in case or errors. (#410)
  • When a transform function is given, transform only TextElements.

fluent 0.13.0

25 Jul 11:47
Compare
Choose a tag to compare
fluent 0.13.0 Pre-release
Pre-release
  • Support Fluent Syntax 1.0.

    Syntax 1.0 is the same as Syntax 0.9, and the support for it in this
    release continues to be the same as in fluent 0.12. This note is meant
    to clearly indicate that fluent supports the first stable version of
    the Syntax specification.

  • Improve the fallback string in case of expression errors.

    Unresolved expressions are now printed with braces around them, e.g.
    {missing} rather than missing (#368). References to missing message
    attributes now fall back to {messageId.attributeName} (#370).

  • Remove the ftl dedent helper.

    The ftl dedent helper has moved to its own package, @fluent/dedent.
    Note that its behavior has changed slightly, too. See the
    README for details.

fluent-syntax 0.14.0

25 Jul 10:50
Compare
Choose a tag to compare
fluent-syntax 0.14.0 Pre-release
Pre-release
  • Deprecate fluent-syntax. Please use @fluent/syntax from now on.

fluent-sequence 0.3.0

25 Jul 12:52
Compare
Choose a tag to compare
fluent-sequence 0.3.0 Pre-release
Pre-release
  • Deprecate fluent-sequence in favor of @fluent/sequence.

fluent-react 0.9.0

25 Jul 14:20
Compare
Choose a tag to compare
fluent-react 0.9.0 Pre-release
Pre-release
  • Deprecate fluent-react in favor of @fluent/react.

fluent-react 0.8.5

25 Jul 13:26
Compare
Choose a tag to compare
fluent-react 0.8.5 Pre-release
Pre-release
  • Accept fluent 0.13.x as a peer dependency.
  • Fix the rendering of empty <Localized/>. (#378)