-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from iroy2000/adding-translation-example
Adding translation example and adding prettier
- Loading branch information
Showing
27 changed files
with
275 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ webpack.config.prod.js | |
/dist | ||
/dist-server | ||
/config/webpack/dist | ||
*.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"trailingComma": "es5", | ||
"semi": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { createStore } from 'redux'; | ||
import { createStore } from 'redux' | ||
|
||
export const getStore = (obj = {}) => createStore((state) => state, obj) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import { IntlProvider, addLocaleData } from 'react-intl' | ||
|
||
// This is react-intl locale data | ||
import en from 'react-intl/locale-data/en' | ||
|
||
// This is your translation files | ||
// In case you are curious about locale - https://gist.github.com/jacobbubu/1836273 | ||
import enUS from 'common/translations/en-US.json' | ||
|
||
// We are adding english here | ||
addLocaleData([...en]); | ||
|
||
// Creating a map of supported messages | ||
// It will be used in IntlProvider below | ||
const messages = { | ||
'en-US': enUS, | ||
} | ||
|
||
export default class I18NProvider extends React.PureComponent { | ||
static propTypes = { | ||
children: PropTypes.element.isRequired, | ||
} | ||
|
||
render() { | ||
// query the browser for language / locale | ||
// feel free to modify this logic to fit your need | ||
const language = navigator.language.split(/[-_]/)[0]; | ||
const locale = navigator.language; | ||
|
||
const { children } = this.props | ||
|
||
return ( | ||
<IntlProvider locale={language} messages={messages[locale]}> | ||
{ children } | ||
</IntlProvider> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"greetings.hello": "Hello, {name}, this is a message from translations!" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export type exampleType = { | ||
title: string, | ||
description: string, | ||
source: string, | ||
} | ||
source: string | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,37 @@ | ||
import createSagaMiddleware from 'redux-saga'; | ||
import { | ||
applyMiddleware, | ||
compose, | ||
createStore, | ||
} from 'redux'; | ||
import createSagaMiddleware from 'redux-saga' | ||
import { applyMiddleware, compose, createStore } from 'redux' | ||
|
||
import sagas from './sagas'; | ||
import rootReducer from './rootReducers'; | ||
import sagas from './sagas' | ||
import rootReducer from './rootReducers' | ||
|
||
// Redux DevTools Extension for Chrome and Firefox | ||
const reduxDevTool = () => { | ||
return typeof window === 'object' | ||
&& typeof window.__REDUX_DEVTOOLS_EXTENSION__ !== 'undefined' ? window.__REDUX_DEVTOOLS_EXTENSION__() : (f) => f; | ||
}; | ||
&& typeof window.__REDUX_DEVTOOLS_EXTENSION__ !== 'undefined' | ||
? window.__REDUX_DEVTOOLS_EXTENSION__() | ||
: (f) => f | ||
} | ||
|
||
export default function configureStore(initialState, history) { | ||
const sagaMiddleware = createSagaMiddleware(); | ||
// history is passed here, for this example, we don't use history | ||
export default function configureStore(initialState, history) { // eslint-disable-line no-unused-vars, max-len | ||
const sagaMiddleware = createSagaMiddleware() | ||
|
||
const middleware = applyMiddleware(sagaMiddleware); | ||
const middleware = applyMiddleware(sagaMiddleware) | ||
|
||
const composedStoreEnhancer = compose(middleware, reduxDevTool()); | ||
const composedStoreEnhancer = compose( | ||
middleware, | ||
reduxDevTool() | ||
) | ||
|
||
const store = composedStoreEnhancer(createStore)(rootReducer, initialState); | ||
const store = composedStoreEnhancer(createStore)(rootReducer, initialState) | ||
|
||
sagaMiddleware.run(sagas); | ||
sagaMiddleware.run(sagas) | ||
|
||
if (module.hot) { | ||
module.hot.accept('./rootReducers', () => { | ||
store.replaceReducer(require('./rootReducers')); | ||
}); | ||
store.replaceReducer(require('./rootReducers')) | ||
}) | ||
} | ||
|
||
return store; | ||
return store | ||
} |
Oops, something went wrong.