i18n bootstrapped and applied for the root module

This commit is contained in:
Sebastian Sdorra
2018-07-24 14:36:14 +02:00
parent f7cab0e026
commit f57d408156
12 changed files with 179 additions and 35 deletions

View File

@@ -1,18 +1,20 @@
//@flow
import React from "react";
import { translate } from "react-i18next";
import Notification from "./Notification";
type Props = {
t: string => string,
error?: Error
};
class ErrorNotification extends React.Component<Props> {
render() {
const { error } = this.props;
const { t, error } = this.props;
if (error) {
return (
<Notification type="danger">
<strong>Error:</strong> {error.message}
<strong>{t("error-notification.prefix")}:</strong> {error.message}
</Notification>
);
}
@@ -20,4 +22,4 @@ class ErrorNotification extends React.Component<Props> {
}
}
export default ErrorNotification;
export default translate("commons")(ErrorNotification);

View File

@@ -1,5 +1,6 @@
//@flow
import React from "react";
import { translate } from "react-i18next";
import injectSheet from "react-jss";
import Image from "../images/loading.svg";
@@ -24,20 +25,21 @@ const styles = {
};
type Props = {
t: string => string,
classes: any
};
class Loading extends React.Component<Props> {
render() {
const { classes } = this.props;
const { t, classes } = this.props;
return (
<div className={classes.wrapper}>
<div className={classes.loading}>
<img className={classes.image} src={Image} alt="Loading ..." />
<img className={classes.image} src={Image} alt={t("loading.alt")} />
</div>
</div>
);
}
}
export default injectSheet(styles)(Loading);
export default injectSheet(styles)(translate("commons")(Loading));

View File

@@ -1,13 +1,17 @@
//@flow
import React from "react";
import { translate } from "react-i18next";
import Image from "../images/logo.png";
type Props = {};
type Props = {
t: string => string
};
class Logo extends React.Component<Props> {
render() {
return <img src={Image} alt="SCM-Manager logo" />;
const { t } = this.props;
return <img src={Image} alt={t("logo.alt")} />;
}
}
export default Logo;
export default translate("commons")(Logo);

View File

@@ -1,20 +1,30 @@
//@flow
import React from "react";
import { translate } from "react-i18next";
import PrimaryNavigationLink from "./PrimaryNavigationLink";
type Props = {};
type Props = {
t: string => string
};
class PrimaryNavigation extends React.Component<Props> {
render() {
const { t } = this.props;
return (
<nav className="tabs is-boxed">
<ul>
<PrimaryNavigationLink to="/users" label="Users" />
<PrimaryNavigationLink to="/logout" label="Logout" />
<PrimaryNavigationLink
to="/users"
label={t("primary-navigation.users")}
/>
<PrimaryNavigationLink
to="/logout"
label={t("primary-navigation.logout")}
/>
</ul>
</nav>
);
}
}
export default PrimaryNavigation;
export default translate("commons")(PrimaryNavigation);