Migrate react-i18next translate components

This commit is contained in:
Florian Scholdei
2019-10-23 15:47:08 +02:00
parent e4668ae304
commit db075974db
121 changed files with 498 additions and 740 deletions

View File

@@ -1,12 +1,11 @@
import React from "react";
import { WithTranslation, withTranslation } from "react-i18next";
import { Repository } from "@scm-manager/ui-types";
import { NavLink } from "@scm-manager/ui-components";
import { translate } from "react-i18next";
type Props = {
type Props = WithTranslation & {
repository: Repository;
editUrl: string;
t: (p: string) => string;
};
class EditRepoNavLink extends React.Component<Props> {
@@ -24,4 +23,4 @@ class EditRepoNavLink extends React.Component<Props> {
}
}
export default translate("repos")(EditRepoNavLink);
export default withTranslation("repos")(EditRepoNavLink);

View File

@@ -1,11 +1,10 @@
import React from "react";
import { NavLink } from "@scm-manager/ui-components";
import { translate } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import { Repository } from "@scm-manager/ui-types";
import { NavLink } from "@scm-manager/ui-components";
type Props = {
type Props = WithTranslation & {
permissionUrl: string;
t: (p: string) => string;
repository: Repository;
};
@@ -22,4 +21,4 @@ class PermissionsNavLink extends React.Component<Props> {
}
}
export default translate("repos")(PermissionsNavLink);
export default withTranslation("repos")(PermissionsNavLink);

View File

@@ -1,12 +1,10 @@
import React from "react";
import { WithTranslation, withTranslation } from "react-i18next";
import { Repository } from "@scm-manager/ui-types";
import { MailLink, DateFromNow } from "@scm-manager/ui-components";
import { translate } from "react-i18next";
type Props = {
type Props = WithTranslation & {
repository: Repository;
// context props
t: (p: string) => string;
};
class RepositoryDetailTable extends React.Component<Props> {
@@ -51,4 +49,4 @@ class RepositoryDetailTable extends React.Component<Props> {
}
}
export default translate("repos")(RepositoryDetailTable);
export default withTranslation("repos")(RepositoryDetailTable);

View File

@@ -1,5 +1,5 @@
import React from "react";
import { Interpolate, translate } from "react-i18next";
import { Trans, WithTranslation, withTranslation } from "react-i18next";
import classNames from "classnames";
import styled from "styled-components";
import { ExtensionPoint } from "@scm-manager/ui-extensions";
@@ -17,12 +17,9 @@ import {
Button
} from "@scm-manager/ui-components";
type Props = {
type Props = WithTranslation & {
changeset: Changeset;
repository: Repository;
// context props
t: (p: string) => string;
};
type State = {
@@ -85,7 +82,7 @@ class ChangesetDetails extends React.Component<Props, State> {
<ChangesetAuthor changeset={changeset} />
</p>
<p>
<Interpolate i18nKey="changeset.summary" id={id} time={date} />
<Trans i18nKey="changeset.summary" values={{ id, time: date }} />
</p>
</div>
<div className="media-right">{this.renderTags()}</div>
@@ -154,4 +151,4 @@ class ChangesetDetails extends React.Component<Props, State> {
};
}
export default translate("repos")(ChangesetDetails);
export default withTranslation("repos")(ChangesetDetails);

View File

@@ -1,17 +1,16 @@
import React from "react";
import { translate } from "react-i18next";
import { Subtitle, InputField, Select, SubmitButton, Textarea } from "@scm-manager/ui-components";
import { WithTranslation, withTranslation } from "react-i18next";
import { ExtensionPoint } from "@scm-manager/ui-extensions";
import { Repository, RepositoryType } from "@scm-manager/ui-types";
import { Subtitle, InputField, Select, SubmitButton, Textarea } from "@scm-manager/ui-components";
import * as validator from "./repositoryValidation";
type Props = {
type Props = WithTranslation & {
submitForm: (p: Repository) => void;
repository?: Repository;
repositoryTypes: RepositoryType[];
namespaceStrategy: string;
loading?: boolean;
t: (p: string) => string;
};
type State = {
@@ -54,10 +53,8 @@ class RepositoryForm extends React.Component<Props, State> {
}
isFalsy(value) {
if (!value) {
return true;
}
return false;
return !value;
}
isValid = () => {
@@ -236,4 +233,4 @@ class RepositoryForm extends React.Component<Props, State> {
};
}
export default translate("repos")(RepositoryForm);
export default withTranslation("repos")(RepositoryForm);