1
0
mirror of https://github.com/NginxProxyManager/nginx-proxy-manager.git synced 2025-11-17 10:22:31 +03:00

Wrap intl in span identifying translation

This commit is contained in:
Jamie Curnow
2025-10-02 23:06:51 +10:00
parent fcb08d3003
commit 227e818040
68 changed files with 1076 additions and 510 deletions

View File

@@ -1,13 +1,9 @@
import type { Certificate } from "src/api/backend";
import { intl } from "src/locale";
import { T } from "src/locale";
interface Props {
certificate?: Certificate;
}
export function CertificateFormatter({ certificate }: Props) {
if (certificate) {
return intl.formatMessage({ id: "lets-encrypt" });
}
return intl.formatMessage({ id: "http-only" });
return <T id={certificate ? "lets-encrypt" : "http-only"} />;
}

View File

@@ -1,4 +1,4 @@
import { DateTimeFormat, intl } from "src/locale";
import { DateTimeFormat, T } from "src/locale";
interface Props {
domains: string[];
@@ -34,7 +34,7 @@ export function DomainsFormatter({ domains, createdOn }: Props) {
</div>
{createdOn ? (
<div className="text-secondary mt-1">
{intl.formatMessage({ id: "created-on" }, { date: DateTimeFormat(createdOn) })}
<T id="created-on" data={{ date: DateTimeFormat(createdOn) }} />
</div>
) : null}
</div>

View File

@@ -1,11 +1,13 @@
import { intl } from "src/locale";
import cn from "classnames";
import { T } from "src/locale";
interface Props {
enabled: boolean;
}
export function EnabledFormatter({ enabled }: Props) {
if (enabled) {
return <span className="badge bg-lime-lt">{intl.formatMessage({ id: "enabled" })}</span>;
}
return <span className="badge bg-red-lt">{intl.formatMessage({ id: "disabled" })}</span>;
return (
<span className={cn("badge", enabled ? "bg-lime-lt" : "bg-red-lt")}>
<T id={enabled ? "enabled" : "disabled"} />
</span>
);
}

View File

@@ -1,10 +1,6 @@
import { IconArrowsCross, IconBolt, IconBoltOff, IconDisc, IconUser } from "@tabler/icons-react";
import type { AuditLog } from "src/api/backend";
import { DateTimeFormat, intl } from "src/locale";
const getEventTitle = (event: AuditLog) => (
<span>{intl.formatMessage({ id: `event.${event.action}-${event.objectType}` })}</span>
);
import { DateTimeFormat, T } from "src/locale";
const getEventValue = (event: AuditLog) => {
switch (event.objectType) {
@@ -63,7 +59,9 @@ export function EventFormatter({ row }: Props) {
return (
<div className="flex-fill">
<div className="font-weight-medium">
{getIcon(row)} {getEventTitle(row)} &mdash; <span className="badge">{getEventValue(row)}</span>
{getIcon(row)}
<T id={`event.${row.action}-${row.objectType}`} />
&mdash; <span className="badge">{getEventValue(row)}</span>
</div>
<div className="text-secondary mt-1">{DateTimeFormat(row.createdOn)}</div>
</div>

View File

@@ -1,4 +1,4 @@
import { intl } from "src/locale";
import { T } from "src/locale";
interface Props {
roles: string[];
@@ -12,7 +12,7 @@ export function RolesFormatter({ roles }: Props) {
<>
{r.map((role: string) => (
<span key={role} className="badge bg-yellow-lt me-1">
{intl.formatMessage({ id: `role.${role}` })}
<T id={`role.${role}`} />
</span>
))}
</>

View File

@@ -1,11 +1,13 @@
import { intl } from "src/locale";
import cn from "classnames";
import { T } from "src/locale";
interface Props {
enabled: boolean;
}
export function StatusFormatter({ enabled }: Props) {
if (enabled) {
return <span className="badge bg-lime-lt">{intl.formatMessage({ id: "online" })}</span>;
}
return <span className="badge bg-red-lt">{intl.formatMessage({ id: "offline" })}</span>;
return (
<span className={cn("badge", enabled ? "bg-lime-lt" : "bg-red-lt")}>
<T id={enabled ? "online" : "offline"} />
</span>
);
}

View File

@@ -1,4 +1,4 @@
import { DateTimeFormat, intl } from "src/locale";
import { DateTimeFormat, T } from "src/locale";
interface Props {
value: string;
@@ -13,9 +13,7 @@ export function ValueWithDateFormatter({ value, createdOn, disabled }: Props) {
</div>
{createdOn ? (
<div className={`text-secondary mt-1 ${disabled ? "text-red" : ""}`}>
{disabled
? intl.formatMessage({ id: "disabled" })
: intl.formatMessage({ id: "created-on" }, { date: DateTimeFormat(createdOn) })}
<T id={disabled ? "disabled" : "created-on"} data={{ date: DateTimeFormat(createdOn) }} />
</div>
) : null}
</div>