mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 16:05:44 +01:00
Migrate react-i18next translate components
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import React from "react";
|
||||
import { translate } from "react-i18next";
|
||||
import { WithTranslation, withTranslation } from "react-i18next";
|
||||
import { Links, Link } from "@scm-manager/ui-types";
|
||||
import { apiClient, SubmitButton, Loading, ErrorNotification } from "../";
|
||||
import { FormEvent } from "react";
|
||||
@@ -10,12 +10,9 @@ type RenderProps = {
|
||||
onConfigurationChange: (p1: ConfigurationType, p2: boolean) => void;
|
||||
};
|
||||
|
||||
type Props = {
|
||||
type Props = WithTranslation & {
|
||||
link: string;
|
||||
render: (props: RenderProps) => any; // ???
|
||||
|
||||
// context props
|
||||
t: (p: string) => string;
|
||||
};
|
||||
|
||||
type ConfigurationType = {
|
||||
@@ -190,4 +187,4 @@ class Configuration extends React.Component<Props, State> {
|
||||
}
|
||||
}
|
||||
|
||||
export default translate("config")(Configuration);
|
||||
export default withTranslation("config")(Configuration);
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from "react";
|
||||
import { binder } from "@scm-manager/ui-extensions";
|
||||
import { NavLink } from "../navigation";
|
||||
import { Route } from "react-router-dom";
|
||||
import { translate } from "react-i18next";
|
||||
import { WithTranslation, withTranslation } from "react-i18next";
|
||||
import { Repository, Links, Link } from "@scm-manager/ui-types";
|
||||
|
||||
type GlobalRouteProps = {
|
||||
@@ -15,6 +15,8 @@ type RepositoryRouteProps = {
|
||||
repository: Repository;
|
||||
};
|
||||
|
||||
type RepositoryNavProps = WithTranslation & { url: string };
|
||||
|
||||
class ConfigurationBinder {
|
||||
i18nNamespace = "plugins";
|
||||
|
||||
@@ -34,7 +36,7 @@ class ConfigurationBinder {
|
||||
};
|
||||
|
||||
// create NavigationLink with translated label
|
||||
const ConfigNavLink = translate(this.i18nNamespace)(({ t }) => {
|
||||
const ConfigNavLink = withTranslation(this.i18nNamespace)(({ t }) => {
|
||||
return this.navLink("/admin/settings" + to, labelI18nKey, t);
|
||||
});
|
||||
|
||||
@@ -64,7 +66,7 @@ class ConfigurationBinder {
|
||||
};
|
||||
|
||||
// create NavigationLink with translated label
|
||||
const RepoNavLink = translate(this.i18nNamespace)(({ t, url }) => {
|
||||
const RepoNavLink = withTranslation(this.i18nNamespace)(({ t, url }: RepositoryNavProps) => {
|
||||
return this.navLink(url + to, labelI18nKey, t);
|
||||
});
|
||||
|
||||
@@ -94,7 +96,7 @@ class ConfigurationBinder {
|
||||
};
|
||||
|
||||
// create NavigationLink with translated label
|
||||
const RepoNavLink = translate(this.i18nNamespace)(({ t, url }) => {
|
||||
const RepoNavLink = withTranslation(this.i18nNamespace)(({ t, url }: RepositoryNavProps) => {
|
||||
return this.navLink(url + "/settings" + to, labelI18nKey, t);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user