mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-28 23:50:08 +00:00
fix(i18n): a quantity under another name than count is a plural group too
The count-string gate only knew {count} and {n}, the params t() picks a
plural form by. A quantity named anything else kept one form in every
language and passed: Russian read "Все {days} дней" for 2 days and
"{objects} объектов" for 3 objects, Greek "{minutes} λεπτά" for 1 minute.
Twelve such en strings become plural groups with their forms in all 27
locales, the quantity renamed to {count}: the trip length limit, the
chat image limit, the API key limit, the storage move prompt and its
reclaimable line, the Dawarich wish rule and suggestion duration, the
road trip lateness warnings, and the road trip echo and window texts.
Their callers pass the count as a number; the storage panels used to
pass it as a string, which no form is picked by. The reclaimable line
loses its dash for a comma in every locale while it is rewritten.
i18n-parity now treats the quantity names in QUANTITY_PARAMS ({days},
{minutes}, {objects}, {max} and the like) like {count}. The four strings
where the number is followed by nothing but a unit symbol (the Dawarich
durations, the upload size limit) go on NOT_PLURAL with that reason.
This commit is contained in:
@@ -982,11 +982,24 @@ describe('AdminStoragePanel', () => {
|
||||
);
|
||||
expect(screen.getByText(/Moving Trip documents… 2\/5/)).toBeInTheDocument();
|
||||
expect(screen.getByText(/Move finished: 4 copied, 0 skipped/)).toBeInTheDocument();
|
||||
expect(screen.getByText(/4 objects \(4\.0 KB\) remain on uploads-local — reclaim manually/)).toBeInTheDocument();
|
||||
expect(screen.getByText(/4 objects \(4\.0 KB\) remain on uploads-local, reclaim manually/)).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Cancel move' }));
|
||||
await waitFor(() => expect(cancelledCategory).toBe('files'));
|
||||
});
|
||||
|
||||
it('FE-ADMIN-STOR-050: the reclaimable line takes the plural form for the object count', async () => {
|
||||
const state = baseState();
|
||||
(state as StorageAdminState).migrations = [
|
||||
{
|
||||
category: 'journey', from: 'uploads-local', to: 'off-box',
|
||||
status: 'done', done: 1, total: 1, copied: 1, skipped: 0, failed: 0, startedAt: 1, finishedAt: 2,
|
||||
reclaimable: { objects: 1, bytes: 1024 },
|
||||
},
|
||||
];
|
||||
await renderPanel(state);
|
||||
expect(screen.getByText(/1 object \(1\.0 KB\) remains on uploads-local, reclaim manually/)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-ADMIN-STOR-038: a done migration with sweep failures shows the doneFailures line; a clean one shows nothing extra', async () => {
|
||||
const state = baseState();
|
||||
(state as StorageAdminState).migrations = [
|
||||
|
||||
@@ -716,7 +716,7 @@ export default function AdminStoragePanel(): React.ReactElement {
|
||||
{m.reclaimable && (
|
||||
<p className={META} style={fs(11.5)}>
|
||||
{t('storage.migrate.reclaimable', {
|
||||
objects: String(m.reclaimable.objects),
|
||||
count: m.reclaimable.objects,
|
||||
size: formatBytes(m.reclaimable.bytes),
|
||||
from: m.from,
|
||||
})}
|
||||
@@ -837,7 +837,7 @@ export default function AdminStoragePanel(): React.ReactElement {
|
||||
})
|
||||
: t('storage.migrate.promptLine', {
|
||||
category: t(`storage.category.${c.category}`),
|
||||
objects: String(c.objects),
|
||||
count: c.objects,
|
||||
size: formatBytes(c.bytes ?? 0),
|
||||
from: c.from,
|
||||
to: c.to,
|
||||
|
||||
@@ -124,7 +124,7 @@ export function useCollabChat(tripId: any, currentUser: any) {
|
||||
const addImageFiles = useCallback((incoming: File[] | FileList) => {
|
||||
images.add(incoming, ({ rejected, overflow }) => {
|
||||
if (rejected) toast.error(t('collab.chat.imageRejected'))
|
||||
if (overflow) toast.error(t('collab.chat.imageLimit', { max: MAX_CHAT_IMAGES }))
|
||||
if (overflow) toast.error(t('collab.chat.imageLimit', { count: MAX_CHAT_IMAGES }))
|
||||
})
|
||||
}, [images, toast, t])
|
||||
const removeImage = images.remove
|
||||
|
||||
@@ -147,7 +147,7 @@ export default function DawarichAcceptDialog({
|
||||
</div>
|
||||
<div className="mt-2 flex flex-wrap items-center gap-1">
|
||||
<DawarichBadge icon={Hourglass} size="sm">
|
||||
{t('dawarich.accept.duration', { minutes: suggestion.durationMinutes })}
|
||||
{t('dawarich.accept.duration', { count: suggestion.durationMinutes })}
|
||||
</DawarichBadge>
|
||||
{/* The source's own verdict, shown here rather than on every row of
|
||||
the list: since Dawarich 1.12.0 "unconfirmed" is the normal state
|
||||
@@ -180,7 +180,7 @@ export default function DawarichAcceptDialog({
|
||||
{' — '}
|
||||
{t('dawarich.bucket.rule', {
|
||||
meters: DAWARICH_BUCKET_MATCH_RADIUS_M,
|
||||
minutes: DAWARICH_BUCKET_MATCH_MIN_MINUTES,
|
||||
count: DAWARICH_BUCKET_MATCH_MIN_MINUTES,
|
||||
})}
|
||||
</span>
|
||||
</p>
|
||||
|
||||
@@ -216,7 +216,7 @@ export default function DawarichAtlasDialog({
|
||||
scan?.truncated ? t('dawarich.bucket.truncated') : null,
|
||||
t('dawarich.bucket.rule', {
|
||||
meters: DAWARICH_BUCKET_MATCH_RADIUS_M,
|
||||
minutes: DAWARICH_BUCKET_MATCH_MIN_MINUTES,
|
||||
count: DAWARICH_BUCKET_MATCH_MIN_MINUTES,
|
||||
}),
|
||||
]}
|
||||
>
|
||||
|
||||
@@ -208,7 +208,7 @@ export function Arrival({ entry }: { entry: ScheduleEntry }): React.ReactElement
|
||||
*/
|
||||
export function LateBadge({ late }: { late: ScheduleWarning }): React.ReactElement {
|
||||
const { t } = useTranslation()
|
||||
const label = t(late.code === 'missedLeave' ? 'roadtrip.warn.missedLeave' : 'roadtrip.warn.late', { minutes: late.minutes ?? 0 })
|
||||
const label = t(late.code === 'missedLeave' ? 'roadtrip.warn.missedLeave' : 'roadtrip.warn.late', { count: late.minutes ?? 0 })
|
||||
// The same two-part shell the stay and the drive findings wear, so a row of badges reads
|
||||
// as one set instead of a pill among boxes.
|
||||
return (
|
||||
|
||||
@@ -264,7 +264,7 @@ function LeaveTime({ stop, leave, until: leaveAt, is12h, onClose }: {
|
||||
{leave.missedBy !== null ? (
|
||||
<p className="flex items-center justify-center gap-1.5 text-center text-body font-medium text-warning">
|
||||
<AlertTriangle size={14} className="shrink-0" aria-hidden />
|
||||
{t('roadtrip.warn.missedLeave', { minutes: leave.missedBy })}
|
||||
{t('roadtrip.warn.missedLeave', { count: leave.missedBy })}
|
||||
</p>
|
||||
) : (
|
||||
<p className="text-center text-body text-content-secondary">
|
||||
|
||||
@@ -250,7 +250,7 @@ export default function ApiKeysSection(): React.ReactElement {
|
||||
{atLimit && (
|
||||
<div className="flex gap-2.5 rounded-[12px] bg-warning-soft px-3.5 py-2.5 text-content" style={fs(12.5, 'body')}>
|
||||
<AlertTriangle size={15} className="mt-px flex-none text-warning" />
|
||||
<p className="m-0 leading-snug">{t('settings.apiKeys.limitReached', { max: MAX_KEYS })}</p>
|
||||
<p className="m-0 leading-snug">{t('settings.apiKeys.limitReached', { count: MAX_KEYS })}</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
@@ -169,7 +169,7 @@ export default function TripFormModal({ isOpen, onClose, onSave, trip, onCoverUp
|
||||
// Only a range being set is held to the limit, as on the server: a trip that
|
||||
// already carries a longer one can still be renamed.
|
||||
const datesTouched = !trip || formData.start_date !== (trip.start_date || '') || formData.end_date !== (trip.end_date || '')
|
||||
if (datesTouched && span > MAX_TRIP_DAYS) { setError(t('dashboard.tripTooLong', { days: MAX_TRIP_DAYS })); return }
|
||||
if (datesTouched && span > MAX_TRIP_DAYS) { setError(t('dashboard.tripTooLong', { count: MAX_TRIP_DAYS })); return }
|
||||
}
|
||||
if (!formData.start_date && !formData.end_date) {
|
||||
const dc = Number(formData.day_count)
|
||||
|
||||
Reference in New Issue
Block a user