• Stars
    star
    265
  • Rank 148,863 (Top 4 %)
  • Language
    JavaScript
  • License
    Other
  • Created over 10 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Handlebars helpers for internationalization.

Handlebars Intl

This library provides Handlebars helpers for internationalization. The helpers provide a declarative way to format dates, numbers, and string messages with pluralization support.

npm Version Build Status Dependency Status

Sauce Test Status

This package used to be named handlebars-helper-intl.

Overview

Handlebars Intl is part of FormatJS, the docs can be found on the webiste: http://formatjs.io/handlebars/

Features

  • Display numbers with separators.
  • Display dates and times correctly.
  • Display dates relative to "now".
  • Pluralize labels in strings.
  • Support for 200+ languages.
  • Runs in the browser and Node.js.
  • Built on standards.

Example

There are many examples on the website, but here's a comprehensive one:

{{formatMessage (intlGet "messages.post.meta")
    num=post.comments.length
    ago=(formatRelative post.date)}}
var context = {
    post: {
        date    : 1422046290531,
        comments: [/*...*/]
    }
};

var intlData = {
    locales : ['en-US'],
    messages: {
        post: {
            meta: 'Posted {ago}, {num, plural, one{# comment} other{# comments}}'
        }
    }
};

var template = Handlebars.compile(/* Template source above */);

var html = template(context, {
    data: {intl: intlData}
});

This example would render: "Posted 3 days ago, 1,000 comments" to the html variable. The post.meta message is written in the industry standard ICU Message syntax, which you can also learn about on the FormatJS website.

Contribute

Let's make Handlebars Intl and FormatJS better! If you're interested in helping, all contributions are welcome and appreciated. Handlebars Intl is just one of many packages that make up the FormatJS suite of packages, and you can contribute to any/all of them, including the Format JS website itself.

Check out the Contributing document for the details. Thanks!

License

This software is free to use under the Yahoo! Inc. BSD license. See the LICENSE file for license text and copyright information.

More Repositories

1

formatjs

The monorepo home to all of the FormatJS related libraries, most notably react-intl.
TypeScript
14,054
star
2

intl-messageformat

[MIGRATED] Format a string with placeholders, including plural and select support to create localized messages.
TypeScript
528
star
3

babel-plugin-react-intl

Extracts string messages from React components that use React Intl.
JavaScript
420
star
4

formatjs-site

Documentation for client/server internationalization in JavaScript.
HTML
315
star
5

intl-relativeformat

Formats JavaScript dates to relative time strings (e.g., "3 hours ago").
TypeScript
212
star
6

formatjs-old

The monorepo home to all of the FormatJS related libraries.
TypeScript
156
star
7

intl-messageformat-parser

[MIGRATED] Parses ICU message strings to an AST that can be used to format the messages for a person's locale.
JavaScript
115
star
8

date-time-format-timezone

Surgically polyfills timezone support in Intl.DateTimeFormat API
JavaScript
108
star
9

intl-locales-supported

[MIGRATED] Utility to help you polyfill the Node.js runtime when the Intl APIs are missing, or if the built-in Intl is missing locale data that you need.
JavaScript
67
star
10

intl-format-cache

Produces instances of JavaScript `Intl` formats, and caches them for reuse.
TypeScript
54
star
11

dust-intl

Dust helpers for internationalization.
JavaScript
48
star
12

js-module-formats

Detect different types of javascript modules formats
JavaScript
13
star
13

input-data-formatter

JavaScript
11
star
14

formatjs-extract-cldr-data

[MIGRATED] Utility library that extracts the CLDR data that's needed by the FormatJS libraries.
JavaScript
11
star
15

grunt-extract-cldr-data

Extract CLDR data and transform it for use in JavaScript.
JavaScript
7
star
16

broccoli-js-module-formats

Broccoli plugin for obtaining files that use a particular module system
JavaScript
2
star
17

formatjs.github.io

Website for formatjs.io
HTML
1
star