Extremely simple i18n support for hadron applications.
npm install --save hadron-i18n
In the renderer process entry point, for example src/renderer/index.js
:
const path = require('path');
const electron = require('electron');
const I18n = require('hadron-i18n');
const LOCALES = path.join(__dirname, 'locales');
new I18n(electron.remote.app.getLocale()).load(LOCALES, (error, i18n) => {
global.t = i18n.t
});
An example locale file, must be .yml
and the filename must be lowercase.
Example en-us.yml
:
toolbar:
home: "Home"
list: "List"
An example React component that uses the translations:
const React = require('react');
class ToolbarComponent extends React.Component {
render() {
return (
<div className="toolbar">
<ol>
<li>{global.t.toolbar.home}</li>
<li>{global.t.toolbar.list}</li>
</ol>
</div>
)
}
}
Apache 2.0