Skip to content

Commit e53da33

Browse files
shuuji3danielroe
andauthored
refactor(i18n): externalize and organize hardcoded strings (#282)
Co-authored-by: Daniel Roe <daniel@roe.dev>
1 parent 4f71ec0 commit e53da33

11 files changed

Lines changed: 33 additions & 18 deletions

File tree

app/app.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ if (import.meta.client) {
5050

5151
<template>
5252
<div class="min-h-screen flex flex-col bg-bg text-fg">
53-
<a href="#main-content" class="skip-link font-mono">Skip to main content</a>
53+
<a href="#main-content" class="skip-link font-mono">{{ $t('common.skip_link') }}</a>
5454

5555
<AppHeader :show-logo="!isHomepage" />
5656

app/components/AccentColorPicker.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { accentColors, selectedAccentColor, setAccentColor } = useAccentColor()
55
</script>
66

77
<template>
8-
<div role="listbox" aria-label="Accent colors" class="flex items-center gap-4">
8+
<div role="listbox" :aria-label="$t('settings.accent_colors')" class="flex items-center gap-4">
99
<button
1010
v-for="color in accentColors"
1111
:key="color.id"
@@ -19,7 +19,7 @@ const { accentColors, selectedAccentColor, setAccentColor } = useAccentColor()
1919
/>
2020
<button
2121
type="button"
22-
aria-label="Clear accent color"
22+
:aria-label="$t('settings.clear_accent')"
2323
class="size-6 rounded-full transition-transform duration-150 motion-safe:hover:scale-110 focus-ring flex items-center justify-center bg-accent-fallback"
2424
@click="setAccentColor(null)"
2525
>

app/components/AppFooter.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<footer class="border-t border-border mt-auto" aria-label="Site footer">
2+
<footer class="border-t border-border mt-auto" :aria-label="$t('footer.site_footer')">
33
<div class="container py-3 sm:py-8 flex flex-col gap-2 sm:gap-4 text-fg-subtle text-sm">
44
<div class="flex flex-col sm:flex-row items-center justify-between gap-2 sm:gap-4">
55
<p class="font-mono m-0 hidden sm:block">{{ $t('tagline') }}</p>

app/components/AppHeader.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ onKeyStroke(',', e => {
4545

4646
<template>
4747
<header
48-
aria-label="Site header"
48+
:aria-label="$t('header.site_header')"
4949
class="sticky top-0 z-50 bg-bg/80 backdrop-blur-md border-b border-border"
5050
>
51-
<nav aria-label="Main navigation" class="container h-14 flex items-center">
51+
<nav :aria-label="$t('nav.main_navigation')" class="container h-14 flex items-center">
5252
<!-- Left: Logo -->
5353
<div class="flex-shrink-0">
5454
<NuxtLink

app/components/ChartModal.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function handleKeydown(event: KeyboardEvent) {
2929
<button
3030
type="button"
3131
class="absolute inset-0 bg-black/60 cursor-default"
32-
aria-label="Close modal"
32+
:aria-label="$t('common.close_modal')"
3333
@click="open = false"
3434
/>
3535

@@ -47,7 +47,7 @@ function handleKeydown(event: KeyboardEvent) {
4747
<button
4848
type="button"
4949
class="text-fg-subtle hover:text-fg transition-colors duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fg/50 rounded"
50-
aria-label="Close"
50+
:aria-label="$t('common.close')"
5151
@click="open = false"
5252
>
5353
<span class="i-carbon-close block w-5 h-5" aria-hidden="true" />

app/components/PackageDependencies.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ const sortedOptionalDependencies = computed(() => {
118118
:title="`${getVulnerableDepInfo(dep)!.counts.total} vulnerabilities`"
119119
>
120120
<span class="i-carbon-security w-3 h-3 block" aria-hidden="true" />
121-
<span class="sr-only">View vulnerabilities</span>
121+
<span class="sr-only">{{ $t('package.dependencies.view_vulnerabilities') }}</span>
122122
</NuxtLink>
123123
<NuxtLink
124124
:to="{ name: 'package', params: { package: [...dep.split('/'), 'v', version] } }"

app/pages/[...package].vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ defineOgImageComponent('Package', {
521521
<!-- Internal navigation: Docs + Code (hidden on mobile, shown in external links instead) -->
522522
<nav
523523
v-if="displayVersion"
524-
aria-label="Package navigation"
524+
:aria-label="$t('package.navigation')"
525525
class="hidden sm:flex items-center gap-1 p-0.5 bg-bg-subtle border border-border-subtle rounded-md shrink-0 ml-auto self-center"
526526
>
527527
<NuxtLink
@@ -831,7 +831,9 @@ defineOgImageComponent('Package', {
831831
<!-- Binary-only packages: Show only execute command (no install) -->
832832
<section v-if="isBinaryOnly" aria-labelledby="run-heading" class="area-install scroll-mt-20">
833833
<div class="flex flex-wrap items-center justify-between mb-3">
834-
<h2 id="run-heading" class="text-xs text-fg-subtle uppercase tracking-wider">Run</h2>
834+
<h2 id="run-heading" class="text-xs text-fg-subtle uppercase tracking-wider">
835+
{{ $t('package.run.title') }}
836+
</h2>
835837
<!-- Package manager tabs -->
836838
<div
837839
class="flex items-center gap-1 p-0.5 bg-bg-subtle border border-border-subtle rounded-md"

app/pages/code/[...path].vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ useSeoMeta({
295295

296296
<!-- Breadcrumb navigation -->
297297
<nav
298-
aria-label="File path"
298+
:aria-label="$t('code.file_path')"
299299
class="flex items-center gap-1 font-mono text-sm overflow-x-auto"
300300
>
301301
<NuxtLink

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ const showEmptyState = computed(() => docsData.value?.status !== 'ok')
156156

157157
<div v-else-if="showEmptyState" class="p-6 sm:p-8 lg:p-12">
158158
<div class="max-w-xl rounded-lg border border-border bg-bg-muted p-6">
159-
<h2 class="font-mono text-lg mb-2">Docs not available</h2>
159+
<h2 class="font-mono text-lg mb-2">{{ $t('package.docs.not_available') }}</h2>
160160
<p class="text-fg-subtle text-sm">
161-
{{ docsData?.message ?? 'We could not generate docs for this version.' }}
161+
{{ docsData?.message ?? $t('package.docs.not_available_detail') }}
162162
</p>
163163
<div class="flex gap-4 mt-4">
164164
<NuxtLink

app/pages/search.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ defineOgImageComponent('Default', {
703703
<!-- Sticky search header - positioned below AppHeader (h-14 = 56px) -->
704704
<header class="sticky top-14 z-40 bg-bg/95 backdrop-blur-sm border-b border-border">
705705
<div class="container-sm py-4">
706-
<h1 class="font-mono text-xl sm:text-2xl font-medium mb-4">search</h1>
706+
<h1 class="font-mono text-xl sm:text-2xl font-medium mb-4">{{ $t('nav.search') }}</h1>
707707

708708
<search>
709709
<form role="search" method="GET" action="/search" class="relative" @submit.prevent>
@@ -755,7 +755,7 @@ defineOgImageComponent('Default', {
755755

756756
<!-- Results area with container padding -->
757757
<div class="container-sm pt-20 pb-6">
758-
<section v-if="query" aria-label="Search results" @keydown="handleResultsKeydown">
758+
<section v-if="query" :aria-label="$t('search.results')" @keydown="handleResultsKeydown">
759759
<!-- Initial loading (only after user interaction, not during view transition) -->
760760
<LoadingSpinner v-if="showSearching" :text="$t('search.searching')" />
761761

0 commit comments

Comments
 (0)