├── .babelrc ├── .eslintrc ├── .gitignore ├── .jshintrc ├── .noderequirer.json ├── .npmignore ├── LICENSE ├── README.md ├── demo ├── App.jsx ├── MessageExample.jsx ├── Source.jsx ├── i18n │ ├── en-US.i18n.json │ ├── fi-FI.i18n.json │ └── ru-RU.i18n.json └── index.js ├── index.html ├── package.json ├── server.js ├── src ├── FormattedMessage.jsx ├── ReactMessageFormat.js ├── getVariableModifiers.js └── index.js ├── static ├── 1.bundle.js ├── 2.bundle.js ├── 3.bundle.js └── bundle.js ├── webpack.config.js └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "stage": 0, 3 | "optional": "runtime" 4 | } -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "babel-eslint", 3 | "rules": { 4 | "no-undef": [2], 5 | "no-trailing-spaces": [1], 6 | "space-before-blocks": [2, "always"], 7 | "no-unused-expressions": [0], 8 | "no-underscore-dangle": [0], 9 | "quote-props": [1, "as-needed"], 10 | "no-multi-spaces": [0], 11 | "no-unused-vars": [1], 12 | "no-loop-func": [0], 13 | "key-spacing": [0], 14 | "max-len": [1, 100], 15 | "strict": [0], 16 | "eol-last": [1], 17 | "no-console": [1], 18 | "indent": [1, 2], 19 | "quotes": [2, "single", "avoid-escape"], 20 | "curly": [0], 21 | 22 | "react/jsx-boolean-value": 1, 23 | "react/jsx-quotes": 1, 24 | "react/jsx-no-undef": 2, 25 | "react/jsx-uses-react": 2, 26 | "react/jsx-uses-vars": 2, 27 | "react/no-did-mount-set-state": 1, 28 | "react/no-did-update-set-state": 1, 29 | "react/no-multi-comp": 0, 30 | "react/no-unknown-property": 1, 31 | "react/react-in-jsx-scope": 1, 32 | "react/self-closing-comp": 1, 33 | "react/wrap-multilines": 1, 34 | 35 | "generator-star-spacing": 0, 36 | "new-cap": 0, 37 | "object-curly-spacing": 0, 38 | "object-shorthand": 0, 39 | 40 | "babel/generator-star-spacing": 1, 41 | "babel/new-cap": 1, 42 | "babel/object-curly-spacing": [1, "always"], 43 | "babel/object-shorthand": 1 44 | }, 45 | "plugins": [ 46 | "react", 47 | "babel" 48 | ], 49 | "settings": { 50 | "ecmascript": 6, 51 | "jsx": true 52 | }, 53 | "env": { 54 | "browser": true, 55 | "node": true 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | npm-debug.log 3 | .DS_Store 4 | lib 5 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "browser": true, 4 | "esnext": true, 5 | "newcap": false 6 | } 7 | -------------------------------------------------------------------------------- /.noderequirer.json: -------------------------------------------------------------------------------- 1 | { 2 | "import": true 3 | } 4 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | static 2 | src 3 | demo 4 | .* 5 | server.js 6 | webpack.config.js 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Alexander Kuznetsov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | react-pagan 2 | =========== 3 | 4 | [TBD] 5 | 6 | License 7 | ------- 8 | 9 | [intl-messageformat](https://github.com/yahoo/intl-messageformat/blob/master/LICENSE): Copyright 2013 Yahoo! Inc., All rights reserved. 10 | -------------------------------------------------------------------------------- /demo/App.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import MessageExample from './MessageExample'; 3 | import { connect } from 'react-redux'; 4 | import componentSource from '!!raw!./MessageExample'; 5 | import { loadLang } from 'redux-pagan'; 6 | import cookie from 'cookie.js'; 7 | import Source from './Source'; 8 | 9 | function getLangData(locale) { 10 | return require('./i18n/' + locale + '.i18n.json'); 11 | } 12 | 13 | const DEFAULT_VALUES = [ 14 | '{', 15 | ` "takenDate": ${new Date().getTime()},`, 16 | ' "numPhotos": 123,', 17 | ' "name": "John Smith"', 18 | '}' 19 | ].join('\n'); 20 | 21 | @connect(state => ({ 22 | lang: state.i18n.get('app'), 23 | locale: state.i18n.locale 24 | })) 25 | export default class App extends Component { 26 | constructor(props) { 27 | super(props); 28 | this.state = { 29 | format: props.lang('text').s, 30 | values: DEFAULT_VALUES 31 | }; 32 | } 33 | 34 | componentDidMount() { 35 | this.props.dispatch(loadLang(cookie.get('lang') || 'en-US', getLangData)); 36 | } 37 | 38 | componentWillReceiveProps(nextProps) { 39 | if (nextProps.locale !== this.props.locale) { 40 | cookie.set('lang', nextProps.locale); 41 | this.setState({ format: nextProps.lang('text') }); 42 | } 43 | } 44 | 45 | render() { 46 | let error = '', values = {}; 47 | 48 | try { 49 | values = JSON.parse(this.state.values); 50 | } catch (err) { 51 | error = err.toString(); 52 | } 53 | 54 | return ( 55 |
56 |
57 |
58 | 65 |
66 |

React-Pagan

67 |
68 |
69 |
70 | 71 |