@@ -3,17 +3,29 @@ import { Palette } from "lucide-react";
33import { Menu } from "@/components/menu" ;
44import { Button } from "@/components/button" ;
55import { cn } from "@/lib/utils" ;
6- import {
7- useTheme ,
8- type ResolvedColorTheme ,
9- type ColorTheme ,
10- COLOR_THEME_OPTIONS ,
11- } from "@/contexts/theme-context" ;
6+ import { defineI18nLabels } from "@/hooks/i18n" ;
7+ import { useTheme , type ColorTheme , COLOR_THEME_OPTIONS } from "@/contexts/theme-context" ;
128
13- const RESOLVED_COLOR_THEME_SHORT : Record < ResolvedColorTheme , string > = {
14- light : "Light" ,
15- dark : "Dark" ,
16- } ;
9+ const appearanceSwitcherLabels = defineI18nLabels ( {
10+ en : {
11+ appearance : "Appearance" ,
12+ chooseAppearance : "Choose appearance" ,
13+ followingSystem : ( props : { resolved : string } ) =>
14+ `Following system — currently ${ props . resolved } ` ,
15+ light : "Light" ,
16+ dark : "Dark" ,
17+ system : "System" ,
18+ } ,
19+ ja : {
20+ appearance : "外観" ,
21+ chooseAppearance : "外観を選択" ,
22+ followingSystem : ( props : { resolved : string } ) => `システムに従う — 現在${ props . resolved } ` ,
23+ light : "ライト" ,
24+ dark : "ダーク" ,
25+ system : "システム" ,
26+ } ,
27+ } ) ;
28+ const useT = appearanceSwitcherLabels . useT ;
1729
1830/**
1931 * Decorative dual swatches for the color theme picker. Light/dark show their surface
@@ -70,11 +82,12 @@ function ColorThemePreviewSwatches({ colorTheme }: { colorTheme: ColorTheme }) {
7082 */
7183function AppearanceSwitcher ( ) {
7284 const { theme, resolvedTheme, setTheme } = useTheme ( ) ;
85+ const t = useT ( ) ;
7386
7487 const triggerTitle =
7588 theme === "system"
76- ? `Following system — currently ${ RESOLVED_COLOR_THEME_SHORT [ resolvedTheme ] } `
77- : "Choose appearance" ;
89+ ? t ( "followingSystem" , { resolved : t ( resolvedTheme ) } )
90+ : t ( "chooseAppearance" ) ;
7891
7992 return (
8093 < Menu . Root modal = { false } >
@@ -85,7 +98,7 @@ function AppearanceSwitcher() {
8598 variant = "outline"
8699 size = "icon"
87100 className = "astw:shrink-0"
88- aria-label = "Appearance"
101+ aria-label = { t ( "appearance" ) }
89102 title = { triggerTitle }
90103 />
91104 }
@@ -97,7 +110,9 @@ function AppearanceSwitcher() {
97110 className = "astw:min-w-[16.5rem] astw:rounded-xl astw:p-3"
98111 >
99112 < Menu . Group >
100- < Menu . GroupLabel className = "astw:px-0 astw:pb-2 astw:pt-0" > Appearance</ Menu . GroupLabel >
113+ < Menu . GroupLabel className = "astw:px-0 astw:pb-2 astw:pt-0" >
114+ { t ( "appearance" ) }
115+ </ Menu . GroupLabel >
101116 < Menu . RadioGroup
102117 className = "astw:grid astw:grid-cols-3 astw:gap-2"
103118 value = { theme }
@@ -112,11 +127,11 @@ function AppearanceSwitcher() {
112127 className = { radioItemClasses ( theme === opt . value ) }
113128 >
114129 < Menu . RadioItemIndicator className = "astw:sr-only" >
115- { opt . label }
130+ { t ( opt . value ) }
116131 </ Menu . RadioItemIndicator >
117132 < ColorThemePreviewSwatches colorTheme = { opt . value } />
118133 < span className = "astw:block astw:w-full astw:truncate astw:px-0.5" >
119- { opt . label }
134+ { t ( opt . value ) }
120135 </ span >
121136 </ Menu . RadioItem >
122137 ) ) }
0 commit comments