项目作者: fazalrasel

项目描述 :
Simple Bangla Intl Support
高级语言: JavaScript
项目地址: git://github.com/fazalrasel/ReactReduxBanglaIntl.git
创建时间: 2017-09-02T16:28:41Z
项目社区:https://github.com/fazalrasel/ReactReduxBanglaIntl

开源协议:

下载


Synopsis

Tiny Simple React Redux Bangla Locale Support.

Code Example

Most of the times I just need to support only two languages (English and Bangla). For this its seems unnecessary to implement
react-intl like packages. As this package is not using Browser Intl API, thus you don’t have to worry about Browser support.
It will work as it just simple javascript.

Installation

npm install react-redux-bangla-intl --save-dev

  1. ### add BanglaIntl Reducer to your store
=at store.js
  1. ..... your other imports....
  2. import {reducer as BanglaIntlReducer} from 'react-redux-bangla-intl';
  3. #import {reducerImmutable as BanglaIntlReducer} from 'react-redux-bangla-intl'; // reducer for immutablejs store.
  4. import { combineReducers } from 'redux';
  5. #import { combineReducers } from 'redux-immutable'; // when immutablejs used.
  1. const store = combineReducers({
  2. ..other reducers..
  3. locale : BanglaIntlReducer,
  4. });

export default store;

API Reference

Changing currentLanguage

You need to dispatch actions to reducer to change currentLanguage. It can be done by direct dispatching action
or from inside redux connected component (mapDispatchToProps).

  1. import {toggleLanguage} from 'react-redux-bangla-intl';
  2. store.dispatch(toggleLanguage());

components

IntlText
  1. props {
  2. en,
  3. bn
  4. }
  5. import {IntlText} from 'react-redux-bangla-intl';
  6. <IntlText en="Bangladesh" bn="বাংলাদেশ"></IntlText>
IntlNumber
  1. props {
  2. value
  3. }
  4. import {IntlNumber} from 'react-redux-bangla-intl';
  5. <IntlNumber value="1234" ></IntlNumber>
IntlCurrency
  1. props {
  2. value: '', // string or number
  3. enSymbol: 'BDT', // any string
  4. bnSymbol: 'টাকা', // any string
  5. enSymbolPosition: 'left', //right
  6. bnSymbolPosition: 'left' // right
  7. }
  8. import {IntlCurrency} from 'react-redux-bangla-intl';
  9. <IntlCurrency value="5050" ></IntlCurrency>

Tests

npm run test

Contributors

Any suggestion is welcome.

License

MIT