Skip to content

Commit 87cbc54

Browse files
committed
fix(i18n): extract untranslated hardcoded strings
1 parent 2501b3c commit 87cbc54

File tree

8 files changed

+162
-26
lines changed

8 files changed

+162
-26
lines changed

app/components/Settings/AccentColorPicker.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ onPrehydrate(el => {
2929
<fieldset
3030
class="flex items-center gap-4 has-[input:focus-visible]:(outline-solid outline-accent/70 outline-offset-4) rounded-xl w-fit"
3131
>
32-
<legend class="sr-only">{{ $t('settings.accent_colors') }}</legend>
32+
<legend class="sr-only">{{ $t('settings.accent_colors.label') }}</legend>
3333
<label
3434
v-for="color in accentColors"
3535
:key="color.id"
@@ -43,7 +43,7 @@ onPrehydrate(el => {
4343
class="sr-only"
4444
:value="color.id"
4545
:checked="selectedAccentColor === color.id || (!selectedAccentColor && color.id === 'sky')"
46-
:aria-label="color.id === 'neutral' ? $t('settings.clear_accent') : color.name"
46+
:aria-label="$t(color.label)"
4747
@change="setAccentColor(color.id)"
4848
/>
4949
<span v-if="color.id === 'neutral'" class="i-lucide:ban size-4 text-bg" aria-hidden="true" />

app/components/Settings/BgThemePicker.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ onPrehydrate(el => {
2727
<fieldset
2828
class="flex items-center gap-4 has-[input:focus-visible]:(outline-solid outline-accent/70 outline-offset-4) rounded-xl w-fit"
2929
>
30-
<legend class="sr-only">{{ $t('settings.background_themes') }}</legend>
30+
<legend class="sr-only">{{ $t('settings.background_themes.label') }}</legend>
3131
<label
3232
v-for="theme in backgroundThemes"
3333
:key="theme.id"
@@ -43,7 +43,7 @@ onPrehydrate(el => {
4343
selectedBackgroundTheme === theme.id ||
4444
(!selectedBackgroundTheme && theme.id === 'neutral')
4545
"
46-
:aria-label="theme.name"
46+
:aria-label="$t(theme.label)"
4747
@change="setBackgroundTheme(theme.id)"
4848
/>
4949
</label>

app/composables/useSettings.ts

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,25 @@ export const useKeyboardShortcuts = createSharedComposable(function useKeyboardS
135135
export function useAccentColor() {
136136
const { settings } = useSettings()
137137
const colorMode = useColorMode()
138+
const { t } = useI18n()
139+
140+
const accentColorLabels = computed<Record<AccentColorId, string>>(() => ({
141+
sky: t('settings.accent_colors.sky'),
142+
coral: t('settings.accent_colors.coral'),
143+
amber: t('settings.accent_colors.amber'),
144+
emerald: t('settings.accent_colors.emerald'),
145+
violet: t('settings.accent_colors.violet'),
146+
magenta: t('settings.accent_colors.magenta'),
147+
neutral: t('settings.clear_accent'),
148+
}))
138149

139150
const accentColors = computed(() => {
140151
const isDark = colorMode.value === 'dark'
141152
const colors = isDark ? ACCENT_COLORS.dark : ACCENT_COLORS.light
142153

143154
return Object.entries(colors).map(([id, value]) => ({
144155
id: id as AccentColorId,
145-
name: id,
156+
label: accentColorLabels.value[id as AccentColorId],
146157
value,
147158
}))
148159
})
@@ -190,12 +201,24 @@ export function useSearchProvider() {
190201
}
191202

192203
export function useBackgroundTheme() {
193-
const backgroundThemes = Object.entries(BACKGROUND_THEMES).map(([id, value]) => ({
194-
id: id as BackgroundThemeId,
195-
name: id,
196-
value,
204+
const { t } = useI18n()
205+
206+
const bgThemeLabels = computed<Record<BackgroundThemeId, string>>(() => ({
207+
neutral: t('settings.background_themes.neutral'),
208+
stone: t('settings.background_themes.stone'),
209+
zinc: t('settings.background_themes.zinc'),
210+
slate: t('settings.background_themes.slate'),
211+
black: t('settings.background_themes.black'),
197212
}))
198213

214+
const backgroundThemes = computed(() =>
215+
Object.entries(BACKGROUND_THEMES).map(([id, value]) => ({
216+
id: id as BackgroundThemeId,
217+
label: bgThemeLabels.value[id as BackgroundThemeId],
218+
value,
219+
})),
220+
)
221+
199222
const { settings } = useSettings()
200223

201224
function setBackgroundTheme(id: BackgroundThemeId | null) {

app/pages/package-docs/[...path].vue

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ definePageMeta({
1010
1111
const route = useRoute('docs')
1212
const router = useRouter()
13+
const { t } = useI18n()
1314
1415
const parsedRoute = computed(() => {
1516
const segments = route.params.path?.filter(Boolean)
@@ -87,7 +88,7 @@ const { data: docsData, status: docsStatus } = useLazyFetch<DocsResponse>(
8788
html: '',
8889
toc: null,
8990
status: 'missing' as const,
90-
message: 'Docs are not available for this version.',
91+
message: t('package.docs.default_not_available'),
9192
}),
9293
},
9394
)
@@ -104,9 +105,11 @@ const versionUrlPattern = computed(
104105
)
105106
106107
const pageTitle = computed(() => {
107-
if (!packageName.value) return 'API Docs - npmx'
108-
if (!resolvedVersion.value) return `${packageName.value} docs - npmx`
109-
return `${packageName.value}@${resolvedVersion.value} docs - npmx`
108+
if (!packageName.value) return t('package.docs.page_title')
109+
if (!resolvedVersion.value) return t('package.docs.page_title_name', { name: packageName.value })
110+
return t('package.docs.page_title_version', {
111+
name: `${packageName.value}@${resolvedVersion.value}`,
112+
})
110113
})
111114
112115
useSeoMeta({
@@ -119,7 +122,7 @@ useSeoMeta({
119122
})
120123
121124
defineOgImageComponent('Default', {
122-
title: () => `${pkg.value?.name ?? 'Package'} - Docs`,
125+
title: () => t('package.docs.og_title', { name: pkg.value?.name ?? 'Package' }),
123126
description: () => pkg.value?.license ?? '',
124127
primaryColor: '#60a5fa',
125128
})
@@ -156,7 +159,7 @@ const stickyStyle = computed(() => {
156159
>
157160
<div class="docs-sidebar sticky overflow-y-auto p-4">
158161
<h2 class="text-xs font-semibold text-fg-subtle uppercase tracking-wider mb-4">
159-
Contents
162+
{{ $t('package.docs.contents') }}
160163
</h2>
161164
<!-- eslint-disable vue/no-v-html -->
162165
<div class="toc-content" v-html="docsData.toc" />
@@ -184,7 +187,7 @@ const stickyStyle = computed(() => {
184187
:to="packageRoute(packageName)"
185188
class="link-subtle font-mono text-sm"
186189
>
187-
View package
190+
{{ $t('package.docs.view_package') }}
188191
</NuxtLink>
189192
</div>
190193
</div>

app/pages/settings.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,15 @@ const setLocale: typeof setNuxti18nLocale = newLocale => {
9696
<!-- Accent colors -->
9797
<div class="space-y-3">
9898
<span class="block text-sm text-fg font-medium">
99-
{{ $t('settings.accent_colors') }}
99+
{{ $t('settings.accent_colors.label') }}
100100
</span>
101101
<SettingsAccentColorPicker />
102102
</div>
103103

104104
<!-- Background themes -->
105105
<div class="space-y-3">
106106
<span class="block text-sm text-fg font-medium">
107-
{{ $t('settings.background_themes') }}
107+
{{ $t('settings.background_themes.label') }}
108108
</span>
109109
<SettingsBgThemePicker />
110110
</div>

i18n/locales/en.json

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,25 @@
148148
"language": "Language",
149149
"help_translate": "Help translate npmx",
150150
"translation_status": "Check global translation status",
151-
"accent_colors": "Accent colors",
151+
"accent_colors": {
152+
"label": "Accent colors",
153+
"sky": "Sky",
154+
"coral": "Coral",
155+
"amber": "Amber",
156+
"emerald": "Emerald",
157+
"violet": "Violet",
158+
"magenta": "Magenta"
159+
},
152160
"clear_accent": "Clear accent color",
153161
"translation_progress": "Translation progress",
154-
"background_themes": "Background shade",
162+
"background_themes": {
163+
"label": "Background shade",
164+
"neutral": "Neutral",
165+
"stone": "Stone",
166+
"zinc": "Zinc",
167+
"slate": "Slate",
168+
"black": "Black"
169+
},
155170
"keyboard_shortcuts_enabled": "Enable keyboard shortcuts",
156171
"keyboard_shortcuts_enabled_description": "Keyboard shortcuts can be disabled if they conflict with other browser or system shortcuts"
157172
},
@@ -309,8 +324,15 @@
309324
"unlike": "Unlike this package"
310325
},
311326
"docs": {
327+
"contents": "Contents",
328+
"default_not_available": "Docs are not available for this version.",
312329
"not_available": "Docs not available",
313-
"not_available_detail": "We could not generate docs for this version."
330+
"not_available_detail": "We could not generate docs for this version.",
331+
"page_title": "API Docs - npmx",
332+
"page_title_name": "{name} docs - npmx",
333+
"page_title_version": "{name} docs - npmx",
334+
"og_title": "{name} - Docs",
335+
"view_package": "View package"
314336
},
315337
"get_started": {
316338
"title": "Get started",

i18n/locales/fr-FR.json

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,25 @@
142142
"theme_system": "Système",
143143
"language": "Langue de l'interface",
144144
"help_translate": "Aidez-nous à traduire npmx",
145-
"accent_colors": "Couleurs d'accentuation",
145+
"accent_colors": {
146+
"label": "Couleurs d'accentuation",
147+
"sky": "Ciel",
148+
"coral": "Corail",
149+
"amber": "Ambre",
150+
"emerald": "Émeraude",
151+
"violet": "Violet",
152+
"magenta": "Magenta"
153+
},
146154
"clear_accent": "Supprimer la couleur d'accentuation",
147155
"translation_progress": "Progression de la traduction",
148-
"background_themes": "Teinte de fond",
156+
"background_themes": {
157+
"label": "Teinte de fond",
158+
"neutral": "Neutre",
159+
"stone": "Pierre",
160+
"zinc": "Zinc",
161+
"slate": "Ardoise",
162+
"black": "Noir"
163+
},
149164
"keyboard_shortcuts_enabled": "Activer les raccourcis clavier",
150165
"keyboard_shortcuts_enabled_description": "Les raccourcis clavier peuvent être désactivés s'ils entrent en conflit avec d'autres raccourcis du navigateur ou du système"
151166
},
@@ -289,8 +304,15 @@
289304
"unlike": "Retirer le like"
290305
},
291306
"docs": {
307+
"contents": "Sommaire",
308+
"default_not_available": "La documentation n'est pas disponible pour cette version.",
292309
"not_available": "Documentation non disponible",
293-
"not_available_detail": "Nous n'avons pas pu générer la documentation pour cette version."
310+
"not_available_detail": "Nous n'avons pas pu générer la documentation pour cette version.",
311+
"page_title": "Documentation API - npmx",
312+
"page_title_name": "Documentation {name} - npmx",
313+
"page_title_version": "Documentation {name} - npmx",
314+
"og_title": "{name} - Documentation",
315+
"view_package": "Voir le paquet"
294316
},
295317
"get_started": {
296318
"title": "Commencer",

i18n/schema.json

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,31 @@
449449
"type": "string"
450450
},
451451
"accent_colors": {
452-
"type": "string"
452+
"type": "object",
453+
"properties": {
454+
"label": {
455+
"type": "string"
456+
},
457+
"sky": {
458+
"type": "string"
459+
},
460+
"coral": {
461+
"type": "string"
462+
},
463+
"amber": {
464+
"type": "string"
465+
},
466+
"emerald": {
467+
"type": "string"
468+
},
469+
"violet": {
470+
"type": "string"
471+
},
472+
"magenta": {
473+
"type": "string"
474+
}
475+
},
476+
"additionalProperties": false
453477
},
454478
"clear_accent": {
455479
"type": "string"
@@ -458,7 +482,28 @@
458482
"type": "string"
459483
},
460484
"background_themes": {
461-
"type": "string"
485+
"type": "object",
486+
"properties": {
487+
"label": {
488+
"type": "string"
489+
},
490+
"neutral": {
491+
"type": "string"
492+
},
493+
"stone": {
494+
"type": "string"
495+
},
496+
"zinc": {
497+
"type": "string"
498+
},
499+
"slate": {
500+
"type": "string"
501+
},
502+
"black": {
503+
"type": "string"
504+
}
505+
},
506+
"additionalProperties": false
462507
},
463508
"keyboard_shortcuts_enabled": {
464509
"type": "string"
@@ -931,11 +976,32 @@
931976
"docs": {
932977
"type": "object",
933978
"properties": {
979+
"contents": {
980+
"type": "string"
981+
},
982+
"default_not_available": {
983+
"type": "string"
984+
},
934985
"not_available": {
935986
"type": "string"
936987
},
937988
"not_available_detail": {
938989
"type": "string"
990+
},
991+
"page_title": {
992+
"type": "string"
993+
},
994+
"page_title_name": {
995+
"type": "string"
996+
},
997+
"page_title_version": {
998+
"type": "string"
999+
},
1000+
"og_title": {
1001+
"type": "string"
1002+
},
1003+
"view_package": {
1004+
"type": "string"
9391005
}
9401006
},
9411007
"additionalProperties": false

0 commit comments

Comments
 (0)