Commit 32ccc2d4 authored by Viacheslav Pavlov's avatar Viacheslav Pavlov Committed by Matija Obreza
Browse files

fixed i18n namespaces for express

parent b0ad8b40
......@@ -227,7 +227,6 @@ module.exports = {
new HtmlWebpackExcludeAssetsPlugin(),
new CopyWebpackPlugin([
{ from: './locales', to: 'locales' },
{ from: './generated/locales', to: 'locales' },
]),
......
......@@ -50,7 +50,9 @@ const SsrI18nProvider = withSSR()(I18nextProvider) as any;
// Configure axios for client
configureBackendApi({ apiUrl: store.getState().applicationConfig.apiUrl || process.env.API_URL || 'http://localhost:8080' });
console.log('Here we are!', i18nClient);
const localeModules = ['client', 'common', 'express'];
const i18nC = i18nClient(localeModules);
console.log('Here we are!', i18nC);
sagaMiddleware.run(saga);
if (__PRELOADED_STATE__ === undefined) {
......@@ -64,7 +66,7 @@ if (__PRELOADED_STATE__ === undefined) {
ReactDOM.render(
<Provider store={store}>
<ConnectedRouter history={history}>
<I18nextProvider i18n={i18nClient}>
<I18nextProvider i18n={ i18nC }>
{renderRoutes(routes)}
</I18nextProvider>
</ConnectedRouter>
......@@ -81,7 +83,7 @@ if (__PRELOADED_STATE__ === undefined) {
ReactDOM.hydrate(
<Provider store={store}>
<ConnectedRouter history={history}>
<SsrI18nProvider i18n={i18nClient} initialLanguage={initialLanguage} initialI18nStore={initialI18nStore}>
<SsrI18nProvider i18n={ i18nC } initialLanguage={initialLanguage} initialI18nStore={initialI18nStore}>
{renderRoutes(routes)}
</SsrI18nProvider>
</ConnectedRouter>
......
{
"user": {}
"user": {
"p": {
"login": {
"youLoggedIn": "You logged in as {{username}}"
}
}
}
}
\ No newline at end of file
......@@ -103,8 +103,12 @@ app.use(express.static(path.join('../assets'), {
immutable: true,
}));
const localeModules = ['client', 'common', 'express'];
const i18nS = i18nServer(localeModules);
// Register i18n
app.use(i18nextMiddleware.handle(i18nServer));
app.use(i18nextMiddleware.handle(i18nS));
// Parse cookies
app.use(cookieParser());
// Relay requests to React
......
{
"p": {
"login": {
"youLoggedIn": "You logged in as {{username}}"
}
}
}
......@@ -29,7 +29,7 @@ class UserDetailsPage extends React.Component<ILoginPageProps> {
}
public render() {
const { login } = this.props;
const { login, t } = this.props;
return !login || !login.user_name ? (
<>
<LoginForm
......@@ -38,8 +38,8 @@ class UserDetailsPage extends React.Component<ILoginPageProps> {
</>
) : (
<div>
You logged in as {login.user_name}
<button onClick={ this.logout }> logout </button>
{ t('express:user.p.login.youLoggedIn', { username: login.user_name })}
<button onClick={ this.logout }>{ t('common:action.logout') }</button>
</div>
);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment