Skip to content

Commit cf190cf

Browse files
committed
fix(i18n): extract untranslated hardcoded strings
1 parent b43cc0a commit cf190cf

33 files changed

+237
-51
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="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="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
@@ -87,15 +87,15 @@ const setLocale: typeof setNuxti18nLocale = newLocale => {
8787
<!-- Accent colors -->
8888
<div class="space-y-3">
8989
<span class="block text-sm text-fg font-medium">
90-
{{ $t('settings.accent_colors') }}
90+
{{ $t('settings.accent_colors.label') }}
9191
</span>
9292
<SettingsAccentColorPicker />
9393
</div>
9494

9595
<!-- Background themes -->
9696
<div class="space-y-3">
9797
<span class="block text-sm text-fg font-medium">
98-
{{ $t('settings.background_themes') }}
98+
{{ $t('settings.background_themes.label') }}
9999
</span>
100100
<SettingsBgThemePicker />
101101
</div>

i18n/locales/ar.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@
105105
"theme_system": "سمة النظام",
106106
"language": "اللغة",
107107
"help_translate": "ساهم في ترجمة npmx",
108-
"accent_colors": "ألوان الموقع",
108+
"accent_colors": {
109+
"label": "ألوان الموقع"
110+
},
109111
"clear_accent": "مسح لون التمييز",
110112
"translation_progress": "تقدم الترجمة",
111113
"background_themes": "درجة خلفية الصفحة"

i18n/locales/az-AZ.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@
142142
"theme_system": "Sistem",
143143
"language": "Dil",
144144
"help_translate": "npmx-i tərcümə etməyə kömək edin",
145-
"accent_colors": "Vurğu rəngləri",
145+
"accent_colors": {
146+
"label": "Vurğu rəngləri"
147+
},
146148
"clear_accent": "Vurğu rəngini təmizlə",
147149
"translation_progress": "Tərcümə irəliləyişi",
148150
"background_themes": "Fon tonu",

i18n/locales/bg-BG.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@
111111
"theme_system": "Системна",
112112
"language": "Език",
113113
"help_translate": "Помогнете да преведем npmx",
114-
"accent_colors": "Акцентни цветове",
114+
"accent_colors": {
115+
"label": "Акцентни цветове"
116+
},
115117
"clear_accent": "Изчистване на акцентен цвят",
116118
"translation_progress": "Напредък на превода",
117119
"background_themes": "Фонов нюанс",

i18n/locales/bn-IN.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@
7474
"theme_system": "সিস্টেম",
7575
"language": "ভাষা",
7676
"help_translate": "npmx অনুবাদে সাহায্য করুন",
77-
"accent_colors": "এক্সেন্ট রং",
77+
"accent_colors": {
78+
"label": "এক্সেন্ট রং"
79+
},
7880
"clear_accent": "এক্সেন্ট রং সাফ করুন",
7981
"translation_progress": "অনুবাদের অগ্রগতি"
8082
},

i18n/locales/cs-CZ.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@
142142
"theme_system": "Systémové",
143143
"language": "Jazyk",
144144
"help_translate": "Pomozte přeložit npmx",
145-
"accent_colors": "Barvy akcentu",
145+
"accent_colors": {
146+
"label": "Barvy akcentu"
147+
},
146148
"clear_accent": "Vymazat barvu akcentu",
147149
"translation_progress": "Pokrok překladu",
148150
"background_themes": "Odstín pozadí",

0 commit comments

Comments
 (0)