fix(i18n): hand Intl and the document the real language tag for br and gr

TREK's codes 'br' (Brazilian Portuguese) and 'gr' (Greek) went straight
into <html lang> and into ten Intl calls. 'br' is Breton, so Brazilian
users got Breton month names and screen readers announced the page as
Breton; 'gr' is no language at all, so Greek users got the default
locale. getIntlLanguage maps both, and every one of those sites goes
through it.
This commit is contained in:
Maurice
2026-10-07 16:34:48 +02:00
parent 461a63fc86
commit 8f02337d45
7 changed files with 46 additions and 13 deletions
+3 -1
View File
@@ -1,3 +1,5 @@
import { getIntlLanguage } from '@trek/shared'
export interface PlaceLocality {
/** The country's name in the reader's language, or as the address spells it. */
country: string | null
@@ -34,7 +36,7 @@ function countryFromAddress(address: string | null | undefined): string | null {
export function placeLocality(place: LocatedPlace, language: string): PlaceLocality {
let country: string | null = null
if (place.country_code) {
try { country = new Intl.DisplayNames([language], { type: 'region' }).of(place.country_code.toUpperCase()) ?? null } catch { country = null }
try { country = new Intl.DisplayNames([getIntlLanguage(language)], { type: 'region' }).of(place.country_code.toUpperCase()) ?? null } catch { country = null }
}
return {
country: country ?? countryFromAddress(place.address),