From 677b7bcaab0109b90590e96dd6e35df4b83d84ea Mon Sep 17 00:00:00 2001 From: Alexis <35.alexis.pele@gmail.com> Date: Fri, 21 Mar 2025 12:03:57 +0100 Subject: [PATCH] Fixed more translations --- astro.config.mjs | 14 ++++++------- src/components/maps/Map.astro | 20 +++++++++++++++---- .../maps/data/en/aldys/markers.json | 2 +- src/components/maps/overlay/SearchMarkers.vue | 4 ++-- src/i18n/store.ts | 6 +++--- src/i18n/ui.ts | 2 ++ 6 files changed, 31 insertions(+), 17 deletions(-) diff --git a/astro.config.mjs b/astro.config.mjs index 88d664e2..1d2974fb 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -11,11 +11,11 @@ export default defineConfig({ integrations: [vue(), sitemap()], output: 'static', site: 'https://maps.alexcreates.fr', - i18n: { - locales: availableLangs, - defaultLocale: defaultLang, - routing: { - prefixDefaultLocale: true, - } - } +// i18n: { +// locales: availableLangs, +// defaultLocale: defaultLang, +// routing: { +// prefixDefaultLocale: true, +// } +// } }); diff --git a/src/components/maps/Map.astro b/src/components/maps/Map.astro index 78642d75..5891ad65 100644 --- a/src/components/maps/Map.astro +++ b/src/components/maps/Map.astro @@ -2,6 +2,8 @@ import type { MapMarker, PlayerMarker } from '@/types/Leaflet'; import type { MapProps } from '@/types/Map'; import MarkerCreator from './overlay/MarkerCreator.vue'; +import { t } from '@/i18n/store'; +import { getLangFromUrl } from '@/i18n/utils'; interface Props extends MapProps {} @@ -17,6 +19,11 @@ const { rulerHideWalkDistance = false, backgroundColor = 'transparent', } = Astro.props + +const lang = getLangFromUrl(Astro.url); + +const byText = t('common.by', lang) +const seeMapText = t('maps.go-to-map', lang) ---
@@ -35,10 +42,15 @@ const { mapWidth, rulerDistanceRatio, rulerMainUnit, - rulerHideWalkDistance + rulerHideWalkDistance, + byText, + seeMapText }} defer > +/** + * LEAFLET MAP SETUP + */ // Units used for convertions to avoid changing original marker coords const xRatio = .68447 const yRatio = .68447 @@ -198,10 +210,10 @@ for (let i = 0; i < markers.length; i++) { popupContent += `
- ${m.title} + ${m.title}
- par ${m.coverAuthor} + ${byText} ${m.coverAuthor}
` @@ -229,7 +241,7 @@ for (let i = 0; i < markers.length; i++) { popupContent += ` - Voir la carte détaillée + ${ seeMapText } diff --git a/src/components/maps/data/en/aldys/markers.json b/src/components/maps/data/en/aldys/markers.json index e6ded0e6..e1fe9f04 100644 --- a/src/components/maps/data/en/aldys/markers.json +++ b/src/components/maps/data/en/aldys/markers.json @@ -222,7 +222,7 @@ "x": 198.0424703459088, "y": -210.9293951755887 }, - "mapId": "/en/aldys/cantane/white-hollow", + "mapId": "/en/aldys/cantane/mines-blanches", "cover": "Les Mines Blanches.png", "coverAuthor": "MeckanicalMind", "coverLink": "https://www.deviantart.com/meckanicalmind/art/R3-Mines-258469134" diff --git a/src/components/maps/overlay/SearchMarkers.vue b/src/components/maps/overlay/SearchMarkers.vue index 7ecd3507..784ea0f7 100644 --- a/src/components/maps/overlay/SearchMarkers.vue +++ b/src/components/maps/overlay/SearchMarkers.vue @@ -241,7 +241,7 @@ function resetAllFields(actionAfter?: "focusAfter") { tabindex="0" :title="m.group === 'quests' ? t('maps.seeQuest') : t('maps.seePlace')" > - +
{{ m.title }} @@ -465,9 +465,9 @@ function resetAllFields(actionAfter?: "focusAfter") { img { display: block; width: 100%; + object-fit: cover; max-height: 22.5dvh; max-height: 22.5vh; - object-fit: cover; } .content-wrapper { diff --git a/src/i18n/store.ts b/src/i18n/store.ts index 6a82c56f..c71ec2c2 100644 --- a/src/i18n/store.ts +++ b/src/i18n/store.ts @@ -7,6 +7,6 @@ export function setLang(lang: Language) { currentLang.set(lang); } -export function t(key: string): string { - return translations[currentLang.get()][key] -} \ No newline at end of file +export function t(key: string, lang: Language = currentLang.get()): string { + return translations[lang][key] +} diff --git a/src/i18n/ui.ts b/src/i18n/ui.ts index 03e5ff21..e50429ee 100644 --- a/src/i18n/ui.ts +++ b/src/i18n/ui.ts @@ -8,6 +8,7 @@ export const translations: LanguageDict = { 'fr': { 'common.title': 'Titre', 'common.create': 'Créer', + 'common.by': 'par', 'continents': 'Continents', 'cities': 'Villes', 'others': 'Autres', @@ -30,6 +31,7 @@ export const translations: LanguageDict = { 'en': { 'common.title': 'Title', 'common.create': 'Create', + 'common.by': 'by', 'continents': 'Continents', 'cities': 'Cities', 'others': 'Others',