Skip to content

Commit f8e6fda

Browse files
committed
feat: translate remaining hardcoded strings + optimize category batch query
1 parent fc04473 commit f8e6fda

File tree

14 files changed

+130
-30
lines changed

14 files changed

+130
-30
lines changed

app/components/PhotoCarousel.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup lang="ts">
22
const { uuid } = defineProps<{ uuid: string }>()
3+
const { t } = useI18n()
34
45
// Try up to 3 photos (blob endpoint limits to 0-2)
56
const MAX_PHOTOS = 3
@@ -17,7 +18,7 @@ const availablePhotos = computed(() => Array.from({ length: MAX_PHOTOS }, (_, i)
1718
<div v-for="(photoIndex, i) in availablePhotos" :key="photoIndex" shrink-0 snap-start first:ps-24 last:pe-24>
1819
<img
1920
:src="`/blob/location/${uuid}/${photoIndex}`"
20-
:alt="`Photo ${photoIndex + 1}`"
21+
:alt="t('photo.alt', { number: photoIndex + 1 })"
2122
:loading="i === 0 ? 'eager' : 'lazy'"
2223
w-280 aspect-0.8 object-cover f-rounded-lg outline="1.5 offset--1.5 white/14"
2324
@error="onError(photoIndex)"

app/composables/useSearchHistory.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ interface SearchHistoryItem {
66

77
const MAX_ITEMS = 8
88

9-
const DEFAULT_CATEGORIES: QuickCategoryItem[] = [
10-
{ category: 'restaurant', label: 'Restaurant', icon: 'i-tabler:tools-kitchen-2', color: 'orange' },
11-
{ category: 'cafe', label: 'Cafe', icon: 'i-tabler:coffee', color: 'gold' },
12-
{ category: 'bar', label: 'Bar', icon: 'i-tabler:beer', color: 'green' },
13-
{ category: 'pharmacy', label: 'Pharmacy', icon: 'i-tabler:pill', color: 'purple' },
9+
const DEFAULT_CATEGORY_IDS = [
10+
{ category: 'restaurant', icon: 'i-tabler:tools-kitchen-2', color: 'orange' as const },
11+
{ category: 'cafe', icon: 'i-tabler:coffee', color: 'gold' as const },
12+
{ category: 'bar', icon: 'i-tabler:beer', color: 'green' as const },
13+
{ category: 'pharmacy', icon: 'i-tabler:pill', color: 'purple' as const },
1414
]
1515

1616
export function useSearchHistory() {
@@ -36,7 +36,12 @@ export function useSearchHistory() {
3636
})
3737

3838
const remaining = 4 - historyItems.length
39-
const defaults = DEFAULT_CATEGORIES.slice(0, remaining)
39+
const defaults = DEFAULT_CATEGORY_IDS.slice(0, remaining).map(({ category, icon, color }): QuickCategoryItem => ({
40+
category,
41+
label: formatCategoryLabel(category),
42+
icon,
43+
color,
44+
}))
4045
return [...historyItems, ...defaults]
4146
}
4247

app/pages/index.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import type { Map } from 'maplibre-gl'
33
import { consola } from 'consola'
44
5+
const { t } = useI18n()
56
const logger = consola.withTag('map')
67
78
definePageMeta({
@@ -221,7 +222,7 @@ async function onMapLoad(event: { map: Map }) {
221222
<template #fallback>
222223
<div flex="~ items-center justify-center" bg-neutral-100 size-screen>
223224
<p text-neutral-700>
224-
Loading map...
225+
{{ t('map.loading') }}
225226
</p>
226227
</div>
227228
</template>

app/plugins/locale-query.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ function isSupportedLocale(lang: unknown): lang is SupportedLocale {
55
return typeof lang === 'string' && supportedLocales.includes(lang as SupportedLocale)
66
}
77

8-
export default defineNuxtPlugin(async () => {
9-
const { setLocale, locale } = useI18n()
8+
export default defineNuxtPlugin(() => {
9+
const { $i18n } = useNuxtApp()
1010
const route = useRoute()
1111
const localeCookie = useCookie<SupportedLocale | null>('i18n_locale', { maxAge: 60 * 60 * 24 * 365 })
1212

1313
const lang = route.query.lang
14-
if (isSupportedLocale(lang) && lang !== locale.value) {
15-
await setLocale(lang)
14+
if (isSupportedLocale(lang) && lang !== $i18n.locale.value) {
15+
$i18n.setLocale(lang)
1616
localeCookie.value = lang
1717
}
1818

1919
// Watch for client navigation with ?lang param
2020
watch(() => route.query.lang, async (newLang) => {
21-
if (isSupportedLocale(newLang) && newLang !== locale.value) {
22-
await setLocale(newLang)
21+
if (isSupportedLocale(newLang) && newLang !== $i18n.locale.value) {
22+
await $i18n.setLocale(newLang)
2323
localeCookie.value = newLang
2424
}
2525
})

i18n/locales/de.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
{
22
"search": {
3-
"placeholder": "Hier suchen"
3+
"placeholder": "Hier suchen",
4+
"nearYou": "{query} in deiner Nähe"
5+
},
6+
"map": {
7+
"loading": "Karte wird geladen..."
8+
},
9+
"photo": {
10+
"alt": "Foto {number}"
411
},
512
"countries": {
613
"SV": "El Salvador",

i18n/locales/en.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
{
22
"search": {
3-
"placeholder": "Search here"
3+
"placeholder": "Search here",
4+
"nearYou": "{query} near you"
5+
},
6+
"map": {
7+
"loading": "Loading map..."
8+
},
9+
"photo": {
10+
"alt": "Photo {number}"
411
},
512
"countries": {
613
"SV": "El Salvador",

i18n/locales/es.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
{
22
"search": {
3-
"placeholder": "Buscar aquí"
3+
"placeholder": "Buscar aquí",
4+
"nearYou": "{query} cerca de ti"
5+
},
6+
"map": {
7+
"loading": "Cargando mapa..."
8+
},
9+
"photo": {
10+
"alt": "Foto {number}"
411
},
512
"countries": {
613
"SV": "El Salvador",

i18n/locales/fr.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
{
22
"search": {
3-
"placeholder": "Rechercher ici"
3+
"placeholder": "Rechercher ici",
4+
"nearYou": "{query} près de vous"
5+
},
6+
"map": {
7+
"loading": "Chargement de la carte..."
8+
},
9+
"photo": {
10+
"alt": "Photo {number}"
411
},
512
"countries": {
613
"SV": "El Salvador",

i18n/locales/pt.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
{
22
"search": {
3-
"placeholder": "Pesquisar aqui"
3+
"placeholder": "Pesquisar aqui",
4+
"nearYou": "{query} perto de você"
5+
},
6+
"map": {
7+
"loading": "Carregando mapa..."
8+
},
9+
"photo": {
10+
"alt": "Foto {number}"
411
},
512
"countries": {
613
"SV": "El Salvador",

nuxt.config.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,5 @@ export default defineNuxtConfig({
9393
include: ['maplibre-gl'],
9494
},
9595
},
96-
nitro: {
97-
preset: 'cloudflare-module',
98-
},
9996
compatibilityDate: '2025-10-01',
10097
})

0 commit comments

Comments
 (0)