From a69078f45180f56b3d143ede34d3893f0a8bce1d Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 4 Jul 2025 12:27:39 +0000 Subject: [PATCH] frontend: Show the geo location of the mirrors Signed-off-by: Michael Tremer --- frontend/src/utils/i18n.ts | 7 +++++++ frontend/src/views/MirrorsView.vue | 6 ++++++ 2 files changed, 13 insertions(+) create mode 100644 frontend/src/utils/i18n.ts diff --git a/frontend/src/utils/i18n.ts b/frontend/src/utils/i18n.ts new file mode 100644 index 00000000..f814eb4d --- /dev/null +++ b/frontend/src/utils/i18n.ts @@ -0,0 +1,7 @@ +// Load the names of regions in the current browser locale +const regions = new Intl.DisplayNames(undefined, { type: "region" }) + +// Returns the country name by its code in the browser's locale +export function getCountryName(cc: string) { + return regions.of(cc) +} diff --git a/frontend/src/views/MirrorsView.vue b/frontend/src/views/MirrorsView.vue index 3b74c422..1323ccfb 100644 --- a/frontend/src/views/MirrorsView.vue +++ b/frontend/src/views/MirrorsView.vue @@ -2,6 +2,7 @@ import { ref, onMounted } from "vue" import type { Mirror } from "@/types/Mirror" import { fetchMirrors } from "@/api/mirrors" + import { getCountryName } from "@/utils/i18n" // Import UI components import Box from "@/components/Box.vue" @@ -27,6 +28,11 @@
+ +
+ {{ getCountryName(mirror.country_code) }} +
+
-- 2.47.2