mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 09:38:54 +00:00
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:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user