wip(i18n): plural forms through Intl.PluralRules

Unfinished, continued in the next session: t() resolves key.one/.few/...
by the language's own plural rule, the parity check knows which forms a
language needs, 16 singular/plural key pairs are merged in every locale
and every count === 1 branch in the client uses the plural form. Still
open: the forms each locale needs for the remaining count strings, the
two new labels in every locale, and 35 tests that expect the old English
wording.
This commit is contained in:
Maurice
2026-10-07 22:57:51 +02:00
parent 588e483205
commit de128cc4ae
271 changed files with 931 additions and 651 deletions
+1 -1
View File
@@ -241,7 +241,7 @@ function PollCard({ poll, currentUser, canEdit, onVote, onClose, onDelete, t }:
{isClosed && <PollChip icon={<Lock size={9} strokeWidth={2.4} />}>{t('collab.polls.closed')}</PollChip>}
{remaining && !isClosed && <PollChip tone="warning" icon={<Clock size={9} strokeWidth={2.4} />}>{remaining}</PollChip>}
{poll.multiple_choice && <PollChip>{t('collab.polls.multiChoice')}</PollChip>}
<PollChip>{t(total === 1 ? 'collab.polls.vote' : 'collab.polls.votes', { n: total })}</PollChip>
<PollChip>{t('collab.polls.votes', { n: total })}</PollChip>
</div>
</div>
{canEdit && (
@@ -56,7 +56,7 @@ export function FilesView(S: FileManagerState) {
}}>{tab.icon ? <tab.icon size={13} fill={filterType === tab.id ? '#facc15' : 'none'} color={filterType === tab.id ? '#facc15' : 'currentColor'} /> : tab.label}</button>
))}
<span style={{ marginLeft: 'auto', fontSize: 'calc(11.5px * var(--fs-scale-caption, 1))', color: 'var(--text-faint)', alignSelf: 'center' }}>
{filteredFiles.length === 1 ? t('files.countSingular') : t('files.count', { count: filteredFiles.length })}
{t('files.count', { count: filteredFiles.length })}
</span>
</div>
@@ -60,13 +60,7 @@ export default function JourneyDayDawarich({
<DawarichIcon size={18} className="shrink-0" />
<span className="min-w-0 flex-1">
<span className="block truncate text-[13px] font-semibold text-content">
{/* Two keys picked by the count, the shape this codebase uses for a number
that changes its noun: there is no plural engine in the i18n layer, and one
key with {count} in it reads as "1 stays". */}
{t(
suggestions.length === 1 ? 'dawarich.journey.dayStays.one' : 'dawarich.journey.dayStays.other',
{ count: suggestions.length },
)}
{t('dawarich.journey.dayStays', { count: suggestions.length })}
</span>
{span && <span className="block text-[11px] text-content-faint tabular-nums">{span}</span>}
</span>
@@ -297,7 +297,7 @@ describe('GalleryView', () => {
await waitFor(() => expect(onRefresh).toHaveBeenCalledTimes(1))
expect(bodies[0]).toEqual({ provider: 'immich', asset_ids: ['asset-1'], media_types: ['image'] })
expect(toastSpy).toHaveBeenCalledWith('1 photos added', 'success', undefined)
expect(toastSpy).toHaveBeenCalledWith('1 photo added', 'success', undefined)
expect(screen.queryByRole('heading', { name: 'Immich' })).not.toBeInTheDocument()
})
@@ -288,7 +288,7 @@ describe('AirTrailImportModal', () => {
await user.click(await screen.findByRole('button', { name: /Import 1/i }));
await waitFor(() => expect(pushUndo).toHaveBeenCalled());
expect(toasts).toContainEqual(['success', '1 flight(s) imported']);
expect(toasts).toContainEqual(['success', '1 flight imported']);
expect(toasts).toContainEqual(['warning', '1 already in this trip, skipped']);
expect(pushUndo.mock.calls[0][0]).toBe('Import from AirTrail');
@@ -247,7 +247,7 @@ describe('AirTrailConnectionSection', () => {
await screen.findByDisplayValue('https://air.example.com');
await user.click(screen.getByRole('button', { name: /Test connection/ }));
await screen.findByText('Connected — 12 flight(s) found');
await screen.findByText('Connected. 12 flights found');
expect(screen.getByText('Connected')).toBeInTheDocument();
expect(body).toEqual({ url: 'https://air.example.com', allowInsecureTls: false });
});
@@ -263,7 +263,7 @@ describe('AirTrailConnectionSection', () => {
await screen.findByDisplayValue('https://air.example.com');
await user.click(screen.getByRole('button', { name: /Test connection/ }));
expect(await screen.findByText('Connected — 0 flight(s) found')).toBeInTheDocument();
expect(await screen.findByText('Connected. 0 flights found')).toBeInTheDocument();
});
it('FE-COMP-AIRTRAIL-015: a refused test shows the returned error and keeps the badge off', async () => {
@@ -319,7 +319,7 @@ describe('OfflineTab', () => {
expect(screen.getByRole('button', { name: 'Downloading…' })).toBeDisabled();
await act(async () => { release(); });
expect(await screen.findByText('Stored 4 trip(s) on this device')).toBeInTheDocument();
expect(await screen.findByText('Stored 4 trips on this device')).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Download for offline use' })).toBeEnabled();
});
+1 -1
View File
@@ -70,7 +70,7 @@ export default function ToursSidebar({ tripId, days, tours, loading = false, sel
// enter the shared store used by the day map.
await onToursChanged?.(result.tours.map(tour => tour.place_id))
await loadTrip(tripId)
toast.success(t(result.tours.length === 1 ? 'tours.import.successOne' : 'tours.import.success', { count: result.tours.length }))
toast.success(t('tours.import.success', { count: result.tours.length }))
if (result.caution) toast.info(t('tours.import.caution'))
} else {
toast.warning(t('places.importAllSkipped'))
@@ -240,7 +240,7 @@ function TripMembersSheet({ isOpen, onClose, tripId, tripTitle, onMembersChanged
<div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 10 }}>
<Users size={13} className="text-content-faint" />
<span className="text-content-secondary" style={{ fontSize: 'calc(12px * var(--fs-scale-body, 1))', fontWeight: 600 }}>
{t('members.access')} ({realMembers.length} {realMembers.length === 1 ? t('members.person') : t('members.persons')})
{t('members.access')} ({realMembers.length} {t('members.persons', { count: realMembers.length })})
</span>
</div>
@@ -41,7 +41,7 @@ function OpenDialog({ onClose, tripId, tripTitle, onMembersChanged }: TripShareD
const labelId = useId()
const m = useTripMembers({ isOpen: true, tripId, onClose, onMembersChanged })
const [ask, setAsk] = useState<Ask | null>(null)
const persons = `${m.realMembers.length} ${m.realMembers.length === 1 ? t('members.person') : t('members.persons')}`
const persons = `${m.realMembers.length} ${t('members.persons', { count: m.realMembers.length })}`
return (
<>
+7 -2
View File
@@ -12,6 +12,7 @@ import {
} from '@trek/shared'
import type { TranslationStrings } from '@trek/shared/i18n'
import { importChunk } from '../utils/chunkReload'
import { resolveTemplate } from './resolveTemplate'
export { SUPPORTED_LANGUAGES }
@@ -134,8 +135,12 @@ export function TranslationProvider({ children }: TranslationProviderProps) {
}, [language])
const value = useMemo((): TranslationContextValue => {
const intlLanguage = getIntlLanguage(language)
const template = (key: string, params?: Record<string, string | number>): string =>
resolveTemplate(strings, intlLanguage, key, params)
function t(key: string, params?: Record<string, string | number>): string {
let val: string = (strings[key] ?? en[key] ?? key) as string
let val = template(key, params)
if (params) {
Object.entries(params).forEach(([k, v]) => {
// Function replacement: a value carrying `$&` or `$1` (a trip named
@@ -147,7 +152,7 @@ export function TranslationProvider({ children }: TranslationProviderProps) {
}
function tHtml(key: string, params?: Record<string, string | number>): string {
let val: string = (strings[key] ?? en[key] ?? key) as string
let val = template(key, params)
if (params) {
Object.entries(params).forEach(([k, v]) => {
// Escape BEFORE substitution so a user-controlled value with `<` or
+48
View File
@@ -0,0 +1,48 @@
import { describe, expect, it } from 'vitest'
import type { TranslationStrings } from '@trek/shared/i18n'
import { resolveTemplate } from './resolveTemplate'
const ru = {
'x.places': '{count} места',
'x.places.one': '{count} место',
'x.places.few': '{count} места',
'x.places.many': '{count} мест',
} as unknown as TranslationStrings
describe('resolveTemplate', () => {
it('picks the form the language selects, not count === 1', () => {
expect(resolveTemplate(ru, 'ru', 'x.places', { count: 1 })).toBe('{count} место')
expect(resolveTemplate(ru, 'ru', 'x.places', { count: 21 })).toBe('{count} место')
expect(resolveTemplate(ru, 'ru', 'x.places', { count: 3 })).toBe('{count} места')
expect(resolveTemplate(ru, 'ru', 'x.places', { count: 5 })).toBe('{count} мест')
expect(resolveTemplate(ru, 'ru', 'x.places', { count: 11 })).toBe('{count} мест')
})
it('a form the locale does not spell out falls back to its general form, never to English', () => {
const ja = { 'x.places': '{count}件の場所' } as unknown as TranslationStrings
expect(resolveTemplate(ja, 'ja', 'x.places', { count: 1 })).toBe('{count}件の場所')
const ruWithoutMany = { 'x.places': '{count} места', 'x.places.one': '{count} место' } as unknown as TranslationStrings
expect(resolveTemplate(ruWithoutMany, 'ru', 'x.places', { count: 5 })).toBe('{count} места')
})
it('a key the locale lacks resolves in English with English rules', () => {
// 'places.count' and its .one form ship in en.
const empty = {} as TranslationStrings
expect(resolveTemplate(empty, 'ru', 'places.count', { count: 1 })).toBe('{count} place')
expect(resolveTemplate(empty, 'ru', 'places.count', { count: 2 })).toBe('{count} places')
})
it('reads n when there is no count, and ignores a count that is not a number', () => {
expect(resolveTemplate(ru, 'ru', 'x.places', { n: 5 })).toBe('{count} мест')
expect(resolveTemplate(ru, 'ru', 'x.places', { count: 'five' })).toBe('{count} места')
expect(resolveTemplate(ru, 'ru', 'x.places', { count: Number.NaN })).toBe('{count} места')
})
it('a group with only category keys still resolves, and an unknown key is the key', () => {
const groupOnly = { 'x.stays.one': 'one stay', 'x.stays.other': '{count} stays' } as unknown as TranslationStrings
expect(resolveTemplate(groupOnly, 'en', 'x.stays', { count: 1 })).toBe('one stay')
expect(resolveTemplate(groupOnly, 'en', 'x.stays', { count: 4 })).toBe('{count} stays')
expect(resolveTemplate(groupOnly, 'en', 'x.nothing', { count: 4 })).toBe('x.nothing')
expect(resolveTemplate(groupOnly, 'en', 'x.nothing')).toBe('x.nothing')
})
})
+28
View File
@@ -0,0 +1,28 @@
import en from '@trek/shared/i18n/en'
import { resolvePluralKey } from '@trek/shared'
import type { TranslationStrings } from '@trek/shared/i18n'
/**
* The template a key reads as. A numeric `count` (or `n`) picks the plural
* form the language's own rule selects (see `@trek/shared` plural helpers):
* `places.count.one`, `.few`, ... and the key itself as the general form.
* The active locale is asked with its rule first; English, with English's,
* only when the locale has none of the key's forms.
*/
export function resolveTemplate(
strings: TranslationStrings,
intlLanguage: string,
key: string,
params?: Record<string, string | number>,
): string {
const raw = params?.count ?? params?.n
const count = typeof raw === 'number' && Number.isFinite(raw) ? raw : undefined
if (count !== undefined) {
const own = resolvePluralKey(strings, key, count, intlLanguage)
if (own) return strings[own] as string
const fallback = resolvePluralKey(en, key, count, 'en')
if (fallback) return en[fallback] as string
return key
}
return (strings[key] ?? en[key] ?? key) as string
}
@@ -403,9 +403,9 @@ function MSpotlightCard({ trip, t, onOpen, actions }: {
</div>
)}
<div className={`flex gap-[6px] ${ongoing ? '' : 'mt-[9px]'}`}>
<SpotlightPill icon={<CalendarDays size={11} strokeWidth={2.2} />} label={days === 1 ? t('dashboard.mobile.spotlightDayOne', { count: days }) : t('dashboard.mobile.spotlightDaysMany', { count: days })} />
<SpotlightPill icon={<MapPin size={11} strokeWidth={2.2} />} label={places === 1 ? t('dashboard.hero.destinationOne', { count: places }) : t('dashboard.hero.destinationMany', { count: places })} />
<SpotlightPill icon={<Users size={11} strokeWidth={2.2} />} label={people === 1 ? t('dashboard.hero.travelerOne', { count: people }) : t('dashboard.hero.travelerMany', { count: people })} />
<SpotlightPill icon={<CalendarDays size={11} strokeWidth={2.2} />} label={t('dashboard.mobile.spotlightDays', { count: days })} />
<SpotlightPill icon={<MapPin size={11} strokeWidth={2.2} />} label={t('dashboard.hero.destinations', { count: places })} />
<SpotlightPill icon={<Users size={11} strokeWidth={2.2} />} label={t('dashboard.hero.travelers', { count: people })} />
</div>
</div>
</div>
@@ -564,7 +564,7 @@ function MTripListCard({ trip, locale, t, badge, pluginBadges, actions, onOpen }
<div className="flex text-center">
<ListStat value={trip.day_count ?? 0} label={t('dashboard.days')} />
<ListStat value={trip.place_count ?? 0} label={t('dashboard.places')} />
<ListStat value={trip.shared_count ?? 0} label={trip.shared_count === 1 ? t('dashboard.card.buddyOne') : t('dashboard.members')} />
<ListStat value={trip.shared_count ?? 0} label={t('dashboard.card.buddies', { count: trip.shared_count ?? 0 })} />
</div>
<MTripBadges items={pluginBadges} />
</div>
@@ -331,7 +331,7 @@ export default function MPlacesBrowser({ planner, shell }: MPlacesBrowserProps)
<div className="mb-1 mt-[14px] flex items-center gap-[10px]">
<span className="h-px flex-1 bg-[color:var(--m-rowbr)]" />
<span className="whitespace-nowrap font-geist text-[0.625rem] font-bold uppercase tracking-[.09em] text-m-faint">
{filtered.length === 1 ? t('places.countSingular') : t('places.count', { count: filtered.length })}
{t('places.count', { count: filtered.length })}
</span>
<span className="h-px flex-1 bg-[color:var(--m-rowbr)]" />
</div>
@@ -187,14 +187,8 @@ function StatusBand({ corridor, t }: { corridor: MRtCorridorController; t: Trans
// The phone's own wording, because the desk's ends in "narrow the corridor" and the
// corridor width is a control this screen deliberately does not have. What it does
// have is the category chips, and fewer of them really is what makes a box fit.
// Two keys picked by the count: the i18n layer has no plural engine, so a single key
// with {count} in a sentence that names the noun once reads as "1 stretches".
if (corridor.truncatedAreas > 0) {
notes.push(
t(corridor.truncatedAreas === 1 ? 'mobileTrip.rtTruncated.one' : 'mobileTrip.rtTruncated.other', {
count: corridor.truncatedAreas,
}),
)
notes.push(t('mobileTrip.rtTruncated', { count: corridor.truncatedAreas }))
}
if (corridor.offline) return <Note tone="warn" icon={<WifiOff size={13} strokeWidth={2} />}>{t('mobileTrip.rtSearchOffline')}</Note>
@@ -281,7 +281,7 @@ function PollCardRow({ poll, canEdit, currentUserId, t, onVote, onClosePoll, onD
</span>
)}
<span className="font-geist text-[0.625rem] text-m-faint">
{t(total === 1 ? 'collab.polls.vote' : 'collab.polls.votes', { n: total })}
{t('collab.polls.votes', { n: total })}
</span>
</div>
</div>
+2 -2
View File
@@ -798,7 +798,7 @@ function SidebarContent({ data, stats, regionsVisited, countryRegions, onOpenPla
<div className="flex flex-col items-center justify-center px-3">
<span className="text-2xl font-black tabular-nums leading-none" style={{ color: tp }}>{streak}</span>
<span className="text-[9px] font-semibold mt-1.5 uppercase tracking-wide text-center leading-tight whitespace-nowrap" style={{ color: tf }}>
{streak === 1 ? t('atlas.yearInRow') : t('atlas.yearsInRow')}
{t('atlas.yearsInRow', { count: streak })}
</span>
</div>
)}
@@ -807,7 +807,7 @@ function SidebarContent({ data, stats, regionsVisited, countryRegions, onOpenPla
<div className="flex flex-col items-center justify-center px-3">
<span className="text-2xl font-black tabular-nums leading-none" style={{ color: tp }}>{tripsThisYear}</span>
<span className="text-[9px] font-semibold mt-1.5 uppercase tracking-wide text-center leading-tight whitespace-nowrap" style={{ color: tf }}>
{tripsThisYear === 1 ? t('atlas.tripIn') : t('atlas.tripsIn')} {thisYear}
{t('atlas.tripsIn', { count: tripsThisYear })} {thisYear}
</span>
</div>
)}
+3 -3
View File
@@ -428,9 +428,9 @@ describe('AtlasPage wiring', () => {
expect(screen.getAllByText('9')).toHaveLength(2);
expect(screen.getAllByText('40')).toHaveLength(2);
expect(screen.getByText('atlas.europe')).toBeInTheDocument();
// Singular labels are picked when streak / tripsThisYear are 1.
expect(screen.getByText('atlas.yearInRow')).toBeInTheDocument();
expect(screen.getByText(/atlas\.tripIn/)).toBeInTheDocument();
// The labels get the counts, so the language's own rule picks the form.
expect(screen.getByText('atlas.yearsInRow:1')).toBeInTheDocument();
expect(screen.getByText(/atlas\.tripsIn:1/)).toBeInTheDocument();
// The last-trip tile used to sit in this row; the row is stats only now.
expect(screen.queryByText('Paris Trip')).not.toBeInTheDocument();
+5 -5
View File
@@ -367,11 +367,11 @@ function BoardingPassHero({ trip, bundle, locale, onOpen, onEdit, onCopy, onArch
const daysLeft = Math.max(0, Math.round((endMid.getTime() - todayMid.getTime()) / MS_PER_DAY))
countdownTop = t('dashboard.status.ongoing')
countdownNumber = String(daysLeft)
countdownLabel = daysLeft === 0 ? t('dashboard.hero.lastDay') : daysLeft === 1 ? t('dashboard.hero.dayLeft') : t('dashboard.hero.daysLeft')
countdownLabel = daysLeft === 0 ? t('dashboard.hero.lastDay') : t('dashboard.hero.daysLeft', { count: daysLeft })
} else if (until !== null && until >= 0) {
countdownTop = t('dashboard.hero.startsIn')
countdownNumber = String(until)
countdownLabel = until === 1 ? t('dashboard.hero.dayUnitOne') : t('dashboard.hero.dayUnitMany')
countdownLabel = t('dashboard.hero.dayUnit', { count: until })
}
const members = bundle?.members || []
@@ -398,7 +398,7 @@ function BoardingPassHero({ trip, bundle, locale, onOpen, onEdit, onCopy, onArch
{members.length > 4 && <div className="buddy-more">+{members.length - 4}</div>}
{members.length === 0 && <div className="buddy-avatar" style={{ background: buddyColor(0) }}>{initials(trip.owner_username)}</div>}
</div>
<div className="date-month">{buddyCount === 1 ? t('dashboard.hero.travelerOne', { count: buddyCount }) : t('dashboard.hero.travelerMany', { count: buddyCount })}</div>
<div className="date-month">{t('dashboard.hero.travelers', { count: buddyCount })}</div>
</div>
<div className="pass-cell dates-combined">
@@ -433,7 +433,7 @@ function BoardingPassHero({ trip, bundle, locale, onOpen, onEdit, onCopy, onArch
{places.length === 0 && <div className="place-more"><MapPin size={15} /></div>}
{places.length > 3 && <div className="place-more">+{places.length - 3}</div>}
</div>
<div className="date-month">{placeCount === 1 ? t('dashboard.hero.destinationOne', { count: placeCount }) : t('dashboard.hero.destinationMany', { count: placeCount })}</div>
<div className="date-month">{t('dashboard.hero.destinations', { count: placeCount })}</div>
</div>
</>
)
@@ -666,7 +666,7 @@ function TripCard({ trip, locale, badges, matchedPlaces, onOpen, onEdit, onCopy,
<div className="trip-meta" style={{ gridTemplateColumns: 'repeat(3, 1fr)' }}>
<div><span className="n mono">{trip.day_count ?? 0}</span><span className="k">{t('dashboard.days')}</span></div>
<div><span className="n mono">{trip.place_count ?? 0}</span><span className="k">{t('dashboard.places')}</span></div>
<div><span className="n mono">{trip.shared_count ?? 0}</span><span className="k">{trip.shared_count === 1 ? t('dashboard.card.buddyOne') : t('dashboard.members')}</span></div>
<div><span className="n mono">{trip.shared_count ?? 0}</span><span className="k">{t('dashboard.card.buddies', { count: trip.shared_count ?? 0 })}</span></div>
</div>
<TripCardBadges items={badges ?? []} />
</div>
+1 -1
View File
@@ -37,7 +37,7 @@ function InAppNotificationsPageDesktop(): React.ReactElement {
)}
</h1>
<p className="text-sm mt-0.5 text-content-muted">
{total} {total === 1 ? 'notification' : 'notifications'}
{total} {t('notifications.countLabel', { count: total })}
</p>
</div>
+1 -6
View File
@@ -112,12 +112,7 @@ export default function OAuthAuthorizePage(): React.ReactElement {
: validation?.scopeSelectable && selectedScopes.length === 0
? t('oauth.authorize.selectScope')
: validation?.scopeSelectable
? t(
selectedScopes.length !== 1
? 'oauth.authorize.approveManyScopes'
: 'oauth.authorize.approveOneScope',
{ count: selectedScopes.length },
)
? t('oauth.authorize.approveScopes', { count: selectedScopes.length })
: t('oauth.authorize.approveAccess')}
</button>
<button type="button"
@@ -227,7 +227,7 @@ describe('AdminUserModals', () => {
fireEvent.click(screen.getByRole('button', { name: /reset passkeys/i }));
confirmPasskeyReset();
await waitFor(() => expect(admin.toast.success).toHaveBeenCalledWith('Removed 3 passkey(s)'));
await waitFor(() => expect(admin.toast.success).toHaveBeenCalledWith('Removed 3 passkeys'));
expect(deletedFor).toBe('2');
});
+3 -3
View File
@@ -625,8 +625,8 @@ export function useAtlas() {
<div style="display:flex;flex-direction:column;gap:8px;min-width:160px">
<div style="font-size:13px;font-weight:600;text-transform:uppercase;letter-spacing:0.1em;padding-bottom:6px;border-bottom:1px solid ${dark ? 'rgba(255,255,255,0.08)' : 'rgba(0,0,0,0.08)'}">${name}${planned ? ` <span style="font-size:9px;font-weight:700;opacity:0.55;letter-spacing:0.06em">· ${t('atlas.planned')}</span>` : ''}</div>
<div style="display:flex;gap:14px">
<div><span style="font-size:16px;font-weight:800">${c.tripCount}</span> <span style="font-size:10px;opacity:0.5;text-transform:uppercase;letter-spacing:0.05em">${c.tripCount === 1 ? t('atlas.tripSingular') : t('atlas.tripPlural')}</span></div>
<div><span style="font-size:16px;font-weight:800">${c.placeCount}</span> <span style="font-size:10px;opacity:0.5;text-transform:uppercase;letter-spacing:0.05em">${c.placeCount === 1 ? t('atlas.placeVisited') : t('atlas.placesVisited')}</span></div>
<div><span style="font-size:16px;font-weight:800">${c.tripCount}</span> <span style="font-size:10px;opacity:0.5;text-transform:uppercase;letter-spacing:0.05em">${t('atlas.tripsLabel', { count: c.tripCount })}</span></div>
<div><span style="font-size:16px;font-weight:800">${c.placeCount}</span> <span style="font-size:10px;opacity:0.5;text-transform:uppercase;letter-spacing:0.05em">${t('atlas.placesVisited', { count: c.placeCount })}</span></div>
</div>
<div style="display:flex;gap:2px;border-top:1px solid ${dark ? 'rgba(255,255,255,0.08)' : 'rgba(0,0,0,0.08)'};padding-top:8px">
${datesHtml}
@@ -895,7 +895,7 @@ export function useAtlas() {
tt.style.left = e.originalEvent.clientX + 12 + 'px'
tt.style.top = e.originalEvent.clientY - 10 + 'px'
tt.innerHTML = visited
? `<div style="font-weight:600;margin-bottom:3px">${regionName}</div><div style="opacity:0.5;font-size:10px">${countryName}</div><div style="margin-top:5px;font-size:11px"><b>${count}</b> ${count === 1 ? 'place' : 'places'}</div>`
? `<div style="font-weight:600;margin-bottom:3px">${regionName}</div><div style="opacity:0.5;font-size:10px">${countryName}</div><div style="margin-top:5px;font-size:11px"><b>${count}</b> ${t('atlas.regionPlacesLabel', { count })}</div>`
: `<div style="font-weight:600;margin-bottom:3px">${regionName}</div><div style="opacity:0.5;font-size:10px">${countryName}</div>`
}
})