Wrap intl in span identifying translation

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

No files matched your search

+50 -22
View File
@@ -1,34 +1,62 @@
import type { Table as ReactTable } from "@tanstack/react-table";
import { intl } from "src/locale";
/**
* This component should never render as there should always be 1 user minimum,
* but I'm keeping it for consistency.
*/
import { T } from "src/locale";
interface Props {
tableInstance: ReactTable<any>;
onNew?: () => void;
onNewCustom?: () => void;
isFiltered?: boolean;
}
export default function Empty({ tableInstance }: Props) {
export default function Empty({ tableInstance, onNew, onNewCustom, isFiltered }: Props) {
return (
<tr>
<td colSpan={tableInstance.getVisibleFlatColumns().length}>
<div className="text-center my-4">
<h2>{intl.formatMessage({ id: "certificates.empty" })}</h2>
<p className="text-muted">{intl.formatMessage({ id: "empty-subtitle" })}</p>
<div className="dropdown">
<button type="button" className="btn dropdown-toggle btn-pink my-3" data-bs-toggle="dropdown">
{intl.formatMessage({ id: "certificates.add" })}
</button>
<div className="dropdown-menu">
<a className="dropdown-item" href="#">
{intl.formatMessage({ id: "lets-encrypt" })}
</a>
<a className="dropdown-item" href="#">
{intl.formatMessage({ id: "certificates.custom" })}
</a>
</div>
</div>
{isFiltered ? (
<h2>
<T id="empty.search" />
</h2>
) : (
<>
<h2>
<T id="certificates.empty" />
</h2>
<p className="text-muted">
<T id="empty-subtitle" />
</p>
<div className="dropdown">
<button
type="button"
className="btn dropdown-toggle btn-pink my-3"
data-bs-toggle="dropdown"
>
<T id="certificates.add" />
</button>
<div className="dropdown-menu">
<a
className="dropdown-item"
href="#"
onClick={(e) => {
e.preventDefault();
onNew?.();
}}
>
<T id="lets-encrypt" />
</a>
<a
className="dropdown-item"
href="#"
onClick={(e) => {
e.preventDefault();
onNewCustom?.();
}}
>
<T id="certificates.custom" />
</a>
</div>
</div>
</>
)}
</div>
</td>
</tr>
+5 -10
View File
@@ -4,7 +4,7 @@ import { useMemo } from "react";
import type { Certificate } from "src/api/backend";
import { DomainsFormatter, GravatarFormatter } from "src/components";
import { TableLayout } from "src/components/Table/TableLayout";
import { intl } from "src/locale";
import { intl, T } from "src/locale";
import Empty from "./Empty";
interface Props {
@@ -69,25 +69,20 @@ export default function Table({ data, isFetching }: Props) {
</button>
<div className="dropdown-menu dropdown-menu-end">
<span className="dropdown-header">
{intl.formatMessage(
{
id: "certificates.actions-title",
},
{ id: info.row.original.id },
)}
<T id="certificates.actions-title" data={{ id: info.row.original.id }} />
</span>
<a className="dropdown-item" href="#">
<IconEdit size={16} />
{intl.formatMessage({ id: "action.edit" })}
<T id="action.edit" />
</a>
<a className="dropdown-item" href="#">
<IconPower size={16} />
{intl.formatMessage({ id: "action.disable" })}
<T id="action.disable" />
</a>
<div className="dropdown-divider" />
<a className="dropdown-item" href="#">
<IconTrash size={16} />
{intl.formatMessage({ id: "action.delete" })}
<T id="action.delete" />
</a>
</div>
</span>
@@ -2,7 +2,7 @@ import { IconSearch } from "@tabler/icons-react";
import Alert from "react-bootstrap/Alert";
import { LoadingPage } from "src/components";
import { useCertificates } from "src/hooks";
import { intl } from "src/locale";
import { T } from "src/locale";
import Table from "./Table";
export default function TableWrapper() {
@@ -28,7 +28,9 @@ export default function TableWrapper() {
<div className="card-header">
<div className="row w-full">
<div className="col">
<h2 className="mt-1 mb-0">{intl.formatMessage({ id: "certificates.title" })}</h2>
<h2 className="mt-1 mb-0">
<T id="certificates.title" />
</h2>
</div>
<div className="col-md-auto col-sm-12">
<div className="ms-auto d-flex flex-wrap btn-list">
@@ -49,14 +51,14 @@ export default function TableWrapper() {
className="btn btn-sm dropdown-toggle btn-pink mt-1"
data-bs-toggle="dropdown"
>
{intl.formatMessage({ id: "certificates.add" })}
<T id="certificates.add" />
</button>
<div className="dropdown-menu">
<a className="dropdown-item" href="#">
{intl.formatMessage({ id: "lets-encrypt" })}
<T id="lets-encrypt" />
</a>
<a className="dropdown-item" href="#">
{intl.formatMessage({ id: "certificates.custom" })}
<T id="certificates.custom" />
</a>
</div>
</div>