Created
December 30, 2015 13:19
-
-
Save nnarhinen/6ce238c7fe2b46ec7c55 to your computer and use it in GitHub Desktop.
i18n in redux react app
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
//omitted a lot | |
translations.fi().then(i18n => { | |
let initialState = { | |
locales: { | |
currentLocale: 'fi', | |
i18n | |
} | |
}; | |
const store = am(createStore)(reducer, initialState); | |
const historyImpl = createBrowserHistory(); | |
ReactDOM.render( | |
<Provider store={store}> | |
<Router history={historyImpl}> | |
</Router> | |
</Provider> | |
, document.getElementById('app') | |
); | |
}); |
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
import Jed from 'jed'; | |
const promiseJed = lang => () => new Promise(resolve => { | |
let messages = require(`bundle?lazy!../locale/${lang}/LC_MESSAGES/messages.po`); | |
messages(msgs => resolve(new Jed(msgs))); | |
}); | |
export default { | |
en: promiseJed('en'), | |
fi: promiseJed('fi') | |
}; |
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
module.exports = { | |
entry: { | |
app: './app.js' | |
}, | |
module: { | |
//other conf | |
loaders: [ | |
//other loaders | |
{ | |
test: /\.jsx?$/, | |
exclude: /node_modules/, | |
loaders: [ | |
'jsxgettext-loader?' + JSON.stringify({outputDir: './locale/templates/LC_MESSAGES', output: 'messages.pot'}), | |
'babel?' + JSON.stringify({presets: ['react', 'es2015']}) | |
] | |
}, | |
} | |
{ | |
test: /\.po$/, | |
loader: 'json!po?format=jed1.x' | |
}] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment