New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-easy-intl

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-easy-intl

React Intl made easy.

  • 1.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-90%
Maintainers
1
Weekly downloads
 
Created
Source

react-easy-intl

Build Status

React Intl made easy.

Introduction

There are a couple big libraries to do i18n in React out there. I've had a hard time setting up both, I don't think it should be so complex.

So I've started baking this quick and dirty intl library based on messageformat.js with ICU support that simply gets the job done. Perhaps not in the best manner, but it fits my needs for a MVP that must be shipped quickly.

Disclaimer

I haven't run any benchmark against this. Improvements and features will be missing.

How to use

Start installing the lib with yarn add react-easy-intl or npm install --save react-easy-intl.

Import the Globalize static class in your main app file to initialise the messages dictionary and set your current locale:

import { Globalize } from 'react-easy-intl'

const messages = {
  en: {
    'Hi #name!': 'Hi {name}!',
    'I have #qty books.': 'I have {qty, plural, =0{no books} one{1 book} other{# books} }.'
  },
  pt: {
    'Hi #name!': 'Olá {name}!',
    'I have #qty books.': 'Eu {qty, plural, =0{não tenho nenhum livro} one{tenho 1 livro} other{tenho # livros} }.'
  }
}

Globalize.setMessages(messages)
Globalize.setLocale('en')

Import the FormatMessage component to start rendering your translated strings:

import { FormatMessage } from 'react-easy-intl'

render () {
  return <FormatMessage name='John Doe'>Hi #name!</FormatMessage>
}

render () {
  return <FormatMessage qty={100}>I have #qty books.</FormatMessage>
}

Contribute

Any help is appreciated on improving this library. There's a lot of room for improvement, such as better messages loading, number and currency formatting, possible support to state management with Redux, etc.

This is just the beginning. Feel free to contribute by opening issues with critiques or suggestions, or by sending pull requests.

License

MIT.

Keywords

FAQs

Package last updated on 01 Feb 2017

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