Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/telecta/react-i18n
React components to integrate rails-i18n, using i18n-js
https://github.com/telecta/react-i18n
Last synced: about 1 month ago
JSON representation
React components to integrate rails-i18n, using i18n-js
- Host: GitHub
- URL: https://github.com/telecta/react-i18n
- Owner: telecta
- License: mit
- Created: 2015-03-24T16:59:29.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2018-05-18T06:31:08.000Z (over 6 years ago)
- Last Synced: 2024-11-17T01:32:08.262Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 41 KB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-i18n
This module integrates with [rails-i18n](https://github.com/svenfuchs/rails-i18n) gem, and built as a wrapper on top of [i18n-js](https://github.com/fnando/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](https://github.com/fnando/i18n-js).
## Usage
### React Mixinimport 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 (
{t('btn_cancel', tOptions)}
);
}
});