fix: translation patterns

This commit is contained in:
Ephraim Atta-Duncan
2025-07-24 16:42:24 +00:00
parent 87e0ea2ee3
commit 582fe91b14
9 changed files with 141 additions and 60 deletions

View File

@ -1,6 +1,7 @@
import type { HTMLAttributes } from 'react';
import { useState } from 'react';
import { msg } from '@lingui/core/macro';
import { useLingui } from '@lingui/react';
import { Trans } from '@lingui/react/macro';
import type { DocumentData } from '@prisma/client';
@ -45,8 +46,8 @@ export const DocumentDownloadButton = ({
setIsLoading(false);
toast({
title: _('Something went wrong'),
description: _('An error occurred while downloading your document.'),
title: _(msg`Something went wrong`),
description: _(msg`An error occurred while downloading your document.`),
variant: 'destructive',
});
}

View File

@ -1,5 +1,3 @@
import { msg } from '@lingui/core/macro';
import { useLingui } from '@lingui/react';
import { Plural, Trans } from '@lingui/react/macro';
import type { Table } from '@tanstack/react-table';
import { ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight } from 'lucide-react';
@ -23,8 +21,6 @@ export function DataTablePagination<TData>({
table,
additionalInformation = 'VisibleCount',
}: DataTablePaginationProps<TData>) {
const { _ } = useLingui();
return (
<div className="flex flex-wrap items-center justify-between gap-x-4 gap-y-4 px-2">
<div className="text-muted-foreground flex-1 text-sm">
@ -90,7 +86,9 @@ export function DataTablePagination<TData>({
onClick={() => table.setPageIndex(0)}
disabled={!table.getCanPreviousPage()}
>
<span className="sr-only">{_(msg`Go to first page`)}</span>
<Trans>
<span className="sr-only">Go to first page</span>
</Trans>
<ChevronsLeft className="h-4 w-4" />
</Button>
<Button
@ -99,7 +97,9 @@ export function DataTablePagination<TData>({
onClick={() => table.previousPage()}
disabled={!table.getCanPreviousPage()}
>
<span className="sr-only">{_(msg`Go to previous page`)}</span>
<Trans>
<span className="sr-only">Go to previous page</span>
</Trans>
<ChevronLeft className="h-4 w-4" />
</Button>
<Button
@ -108,7 +108,9 @@ export function DataTablePagination<TData>({
onClick={() => table.nextPage()}
disabled={!table.getCanNextPage()}
>
<span className="sr-only">{_(msg`Go to next page`)}</span>
<Trans>
<span className="sr-only">Go to next page</span>
</Trans>
<ChevronRight className="h-4 w-4" />
</Button>
<Button
@ -117,7 +119,9 @@ export function DataTablePagination<TData>({
onClick={() => table.setPageIndex(table.getPageCount() - 1)}
disabled={!table.getCanNextPage()}
>
<span className="sr-only">{_(msg`Go to last page`)}</span>
<Trans>
<span className="sr-only">Go to last page</span>
</Trans>
<ChevronsRight className="h-4 w-4" />
</Button>
</div>

View File

@ -3,6 +3,7 @@ import * as React from 'react';
import type { MessageDescriptor } from '@lingui/core';
import { msg } from '@lingui/core/macro';
import { useLingui } from '@lingui/react';
import { Trans } from '@lingui/react/macro';
import type { Column } from '@tanstack/react-table';
import { Check } from 'lucide-react';
@ -83,7 +84,9 @@ export function DataTableFacetedFilter<TData, TValue>({
<PopoverContent className="w-[200px] p-0" align="start">
<Command>
<CommandList>
<CommandEmpty>{_(msg`No results found.`)}</CommandEmpty>
<CommandEmpty>
<Trans>No results found.</Trans>
</CommandEmpty>
<CommandGroup>
{options.map((option) => {
const isSelected = selectedValuesSet.has(option.value);

View File

@ -1,3 +1,4 @@
import { Trans } from '@lingui/react/macro';
import type { Table } from '@tanstack/react-table';
import { ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight } from 'lucide-react';
@ -12,12 +13,16 @@ export function DataTablePagination<TData>({ table }: DataTablePaginationProps<T
return (
<div className="flex items-center justify-between px-2">
<div className="text-muted-foreground flex-1 text-sm">
{table.getFilteredSelectedRowModel().rows.length} of{' '}
{table.getFilteredRowModel().rows.length} row(s) selected.
<Trans>
{table.getFilteredSelectedRowModel().rows.length} of{' '}
{table.getFilteredRowModel().rows.length} row(s) selected.
</Trans>
</div>
<div className="flex items-center space-x-6 lg:space-x-8">
<div className="flex items-center space-x-2">
<p className="text-sm font-medium">Rows per page</p>
<p className="text-sm font-medium">
<Trans>Rows per page</Trans>
</p>
<Select
value={`${table.getState().pagination.pageSize}`}
onValueChange={(value) => {
@ -37,7 +42,9 @@ export function DataTablePagination<TData>({ table }: DataTablePaginationProps<T
</Select>
</div>
<div className="flex w-[100px] items-center justify-center text-sm font-medium">
Page {table.getState().pagination.pageIndex + 1} of {table.getPageCount()}
<Trans>
Page {table.getState().pagination.pageIndex + 1} of {table.getPageCount()}
</Trans>
</div>
<div className="flex items-center space-x-2">
<Button
@ -46,7 +53,9 @@ export function DataTablePagination<TData>({ table }: DataTablePaginationProps<T
onClick={() => table.setPageIndex(0)}
disabled={!table.getCanPreviousPage()}
>
<span className="sr-only">Go to first page</span>
<Trans>
<span className="sr-only">Go to first page</span>
</Trans>
<ChevronsLeft />
</Button>
<Button
@ -55,7 +64,9 @@ export function DataTablePagination<TData>({ table }: DataTablePaginationProps<T
onClick={() => table.previousPage()}
disabled={!table.getCanPreviousPage()}
>
<span className="sr-only">Go to previous page</span>
<Trans>
<span className="sr-only">Go to previous page</span>
</Trans>
<ChevronLeft />
</Button>
<Button
@ -64,7 +75,9 @@ export function DataTablePagination<TData>({ table }: DataTablePaginationProps<T
onClick={() => table.nextPage()}
disabled={!table.getCanNextPage()}
>
<span className="sr-only">Go to next page</span>
<Trans>
<span className="sr-only">Go to next page</span>
</Trans>
<ChevronRight />
</Button>
<Button
@ -73,7 +86,9 @@ export function DataTablePagination<TData>({ table }: DataTablePaginationProps<T
onClick={() => table.setPageIndex(table.getPageCount() - 1)}
disabled={!table.getCanNextPage()}
>
<span className="sr-only">Go to last page</span>
<Trans>
<span className="sr-only">Go to last page</span>
</Trans>
<ChevronsRight />
</Button>
</div>