feat: auto translate

This commit is contained in:
2023-11-06 13:32:02 +00:00
parent e0b68ae817
commit 6e349051a2
5 changed files with 49 additions and 27 deletions

View File

@ -524,11 +524,11 @@ export function getDisplayNameOrPlaceHolder(user: UserMetadata | undefined, pubk
export function getCountry() {
const tz = Intl.DateTimeFormat().resolvedOptions();
const info = (TZ as Record<string, Array<string>>)[tz.timeZone];
const [,lat, lon] = info[1].split(/[-+]/);
const info = (TZ as Record<string, Array<string> | undefined>)[tz.timeZone];
const [, lat, lon] = info?.[1].split(/[-+]/) ?? ["", "00", "000"];
return {
zone: tz.timeZone,
country: info[0],
country: info?.[0],
lat: Number(lat) / Math.pow(10, lat.length - 2),
lon: Number(lon) / Math.pow(10, lon.length - 3),
};