Socket
Socket
Sign inDemoInstall

formatjs-helper

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

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.


Version published
Weekly downloads
945
increased by54.66%
Maintainers
1
Install size
7.80 kB
Created
Weekly downloads
 

Readme

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, initialize the object with your message data (formatted according to ICU Message Syntax) as the single parameter:

formatJSHelper.initialize({
  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:

npm test

License

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

Keywords

FAQs

Last updated on 01 Jun 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc