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

react-i18n

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-i18n

i18n-js integration with React

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
566
increased by21.46%
Maintainers
1
Weekly downloads
 
Created
Source

react-i18n

This module integrates with rails-i18n gem, and built as a wrapper on top of i18n-js.

Basic Setup

Install module

$ npm install --save i18n-js react-i18n

Setting up i18n-js

In Gemfile

gem 'i18n-js'

In your view *.haml

:javascript
	I18n.defaultLocale = "#{I18n.default_locale}";
	I18n.locale = "#{I18n.locale}";
	I18n.fallbacks = true;

= javascript_include_tag "i18n"
= javascript_include_tag "translations"

For more options/details, please refer to the documentation at i18n-js.

Usage

React Mixin

import ReactI18n from 'react-i18n'

let OrderFormButton = React.createClass({
	mixins: [ReactI18n.Mixin],
	render () => {
		let t = this.getIntlMessage; // ReactI18n method
		
		console.log(I18n.locale);
		// "en"
		
		console.log(I18n.translations); 
		// {en: {order_form: { btn_cancel: 'Cancel Order #%{order_id}'}} 
					
		let tOptions = {scope: 'order_form', order_id: this.props.orderId};
		return (
			<button>
				{t('btn_cancel', tOptions)}
			</button>);
	}
});

Keywords

FAQs

Package last updated on 18 May 2018

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