Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

formatjs-helper

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

formatjs-helper

FormatJSHelper is a simple wrapper for your localization message data that makes working with data in the formats needed by FormatJS easy.

  • 2.0.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

FormatJSHelper

FormatJSHelper is a simple wrapper for your localization message data that makes working with data in the formats needed by FormatJS easy.

Usage

To start, create an instance of the class with your message data (formatted according to ICU Message Syntax) as the single parameter:

var formatJSHelper = new FormatJSHelper({
  locales: 'en-US',
  messages: {...}
});

Then you're ready to use FormatJSHelper. A simple usage is getting a string from your messages:

formatJSHelper.get('path', 'to', 'your', 'message');

If you want to format that message using FormatJS's IntlMessageFormat, this is what you would do:

var message = new IntlMessageFormat(formatJSHelper.get('path', 'to', 'your', 'message'), formatJSHelper.getLocale());
message.format();

If you're using FormatJS with templates, the format that the localization data is required in is slightly different, but you can easily fetch what you need in this format like this:

  myHandlebarsTemplate({
    ...
  }, formatJSHelper.getOptions());

To see all methods available for FormatJSHelper, check out the well-documented source!

Tests

Tests are located in the spec/ folder. You can run them with the command:

jasmine

License

This project is licensed under the Apache License v2.0. See LICENSE.md.

Keywords

FAQs

Package last updated on 18 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc