fluxible-plugin-locale-counterpart

0.0.3 • Public • Published

fluxible-plugin-locale-counterpart

Counterpart locale setting plugin for fluxible.

Use for building beautiful isomorphic app translations.

Installation

npm install fluxible-plugin-locale-counterpart --save

Usage

You need to set locale cookie yourself or using LocaleSwitcher code below.

import localePlugin from "fluxible-plugin-locale-counterpart";
 
app.plug(localePlugin);

I use react-translate-component in my application.

Here's how LocaleSwitcher looks like:

import React from "react";
import counterpart from "counterpart";
import {Input} from "react-bootstrap";
import Cookies from "cookies-js";
 
let LocaleSwitcher = React.createClass({
  handleChange: function(e) {
    counterpart.setLocale(e.target.value);
    Cookies.set('locale', e.target.value);
  },
 
  render: function() {
    return (
      <Input
        type="select"
        className="input-sm"
        groupClassName="form-inline form-menu-inline"
        defaultValue={counterpart.getLocale()}
        onChange={this.handleChange}
        >
        <option value="en">English</option>
        <option value="ru">Русский</option>
      </Input>
    );
  }
});
 
export default LocaleSwitcher;

Package Sidebar

Install

npm i fluxible-plugin-locale-counterpart

Weekly Downloads

2

Version

0.0.3

License

MIT

Last publish

Collaborators

  • dwr