Added lang store

This commit is contained in:
Alexis
2025-03-20 15:44:11 +01:00
parent e70841e7b4
commit 99aa951d47
7 changed files with 91 additions and 16 deletions

View File

@@ -3,7 +3,7 @@
{
"group": "capitals",
"title": "Ambrose",
"description": "Capital of Nacride and Economic Capital of the Kaldelian Alliance.",
"description": "Capital of Nacride and bustling economic center of the Kaldelium Accord.",
"link": "https://wiki.alexcreates.fr/index.php/Ambrose",
"markerCoords": {
"x": 83.6,
@@ -16,7 +16,7 @@
{
"group": "capitals",
"title": "Cordouac",
"description": "Capital of Heraldy and Administrative Capital of the Kaldelian Alliance.",
"description": "Capital of Heraldy and administrative core of the Kaldelium Accord.",
"link": "https://wiki.alexcreates.fr/index.php/Cordouac",
"markerCoords": {
"x": 133.46875,
@@ -28,7 +28,7 @@
},
{
"group": "capitals",
"title": "Bordelac",
"title": "Shorehaven",
"description": "Capital of the High Banks",
"link": "https://wiki.alexcreates.fr/index.php/Bordelac",
"markerCoords": {
@@ -38,8 +38,8 @@
},
{
"group": "capitals",
"title": "Tourgrise",
"description": "Capital of Ternacre. It's a city of archivist mages, but it also houses the largest prison population in the Alliance.",
"title": "Grayspire",
"description": "Capital of Ternacre. It's a city of archivist mages, but it also houses the largest prison population in the Accord.",
"link": "https://wiki.alexcreates.fr/index.php/Tourgrise",
"markerCoords": {
"x": 132.26953,
@@ -52,7 +52,7 @@
},
{
"group": "capitals",
"title": "Valsoie",
"title": "Silkdale",
"description": "Capital of Mireloin.",
"link": "https://wiki.alexcreates.fr/index.php/Valsoie",
"markerCoords": {
@@ -72,8 +72,8 @@
},
{
"group": "capitals",
"title": "Port-brisé",
"description": "Chef-lieu d'Émerose.",
"title": "Shattered Port",
"description": "Capital of Émerose.",
"link": "https://wiki.alexcreates.fr/index.php/Port-brisé",
"markerCoords": {
"x": 168.39491,
@@ -879,8 +879,8 @@
},
{
"group": "landmarks",
"title": "Central Kaldelian Academy",
"description": "One of the Alliance's largest magic academies. The entrance exam is open to the public, but students must pay their own tuition fees.",
"title": "Central Kaldelium Academy",
"description": "One of the Accord's largest magic academies. The entrance exam is open to the public, but students must pay their own tuition fees.",
"link": "https://wiki.alexcreates.fr/index.php/Acad%C3%A9mie_Centrale_Kald%C3%A9lienne",
"markerCoords": {
"x": 83.80737652386473,
@@ -916,7 +916,7 @@
{
"group": "landmarks",
"title": "Whitesteel Institute",
"description": "First military school of the Kaldelian Alliance.",
"description": "First military school of the Kaldelium Accord.",
"link": "https://wiki.alexcreates.fr/index.php/Institut_du_Fer_Blanc",
"markerCoords": {
"x": 140.3159943633407,

View File

@@ -1,7 +1,12 @@
<script lang="ts" setup>
import { PopoverArrow, PopoverContent, PopoverRoot, PopoverTrigger } from 'radix-vue'
import { computed, onUpdated, ref, watch } from 'vue';
import { useElementHover, useFocus } from '@vueuse/core'
import { PopoverArrow, PopoverContent, PopoverRoot, PopoverTrigger } from 'radix-vue'
import { useStore } from '@nanostores/vue';
import { currentLang } from '@/i18n/store';
const $currentLang = useStore(currentLang);
const navModel = ref(false);

View File

@@ -1,12 +1,19 @@
<script setup lang="ts">
import { useStore } from '@nanostores/vue';
import { onClickOutside, useFocus, useFocusWithin, useLocalStorage, useMagicKeys, whenever } from '@vueuse/core';
import { computed, onMounted, onUpdated, ref, watch } from 'vue';
import type { MapMarker, MapMarkerGroup, PlayerMarker } from '@/types/Leaflet';
import type { SearchConfig } from '@/types/Map';
import type { SearchMode } from '@/types/Search';
import { onClickOutside, useFocus, useFocusWithin, useLocalStorage, useMagicKeys, whenever } from '@vueuse/core';
import { computed, onMounted, onUpdated, ref, watch } from 'vue';
import { currentLang } from '@/i18n/store';
import SearchMapSwitch from './SearchMapSwitch.vue';
import SearchMarkersTags from './SearchMarkersTags.vue';
const $currentLang = useStore(currentLang);
const props = defineProps<{
markers: MapMarker[],
players: PlayerMarker,

8
src/i18n/store.ts Normal file
View File

@@ -0,0 +1,8 @@
import { type Language } from './ui';
import { persistentAtom } from '@nanostores/persistent';
export const currentLang = persistentAtom<Language>('lang', "fr");
export function setLang(lang: Language) {
currentLang.set(lang);
}

View File

@@ -6,7 +6,6 @@ import type { Head } from '@/types/Head';
interface Props {
title: string
head?: Head
lang?: Language
}
const { title, head } = Astro.props;
@@ -17,6 +16,15 @@ const lang = getLangFromUrl(Astro.url) || defaultLang;
<!doctype html>
<html lang={lang}>
<head>
<script>
import { setLang } from "@/i18n/store";
import { defaultLang, type Language } from "@/i18n/ui";
import { getLangFromUrl } from "@/i18n/utils";
const currentLang: Language = getLangFromUrl(new URL(window.location.href)) || defaultLang;
setLang(currentLang || defaultLang);
</script>
<meta charset="UTF-8" />
<meta name="author" content="Alexis Pelé" />
{head?.description && <meta name="description" content={head.description} /> }
@@ -43,7 +51,7 @@ const lang = getLangFromUrl(Astro.url) || defaultLang;
{head?.image && <meta property="twitter:image" content={head.image} />}
<link rel="stylesheet" href="/leaflet/leaflet.css" rel="preload" />
<script is:inline src="/leaflet/leaflet.js"></script>
<script is:inline src="/leaflet/leaflet.js" />
<script is:inline type="text/javascript" src="/js/leaflet-zoomify.min.js"></script>