@@ -16,6 +16,7 @@ import { useNavStore, type NavItem } from '@/components/modules/navbar';
1616import { CreateDialogContent as ChannelCreateContent } from '@/components/modules/channel/Create' ;
1717import { CreateDialogContent as GroupCreateContent } from '@/components/modules/group/Create' ;
1818import { CreateDialogContent as ModelCreateContent } from '@/components/modules/model/Create' ;
19+ import { useTranslations } from 'next-intl' ;
1920import { useSearchStore } from './search-store' ;
2021import {
2122 useToolbarViewOptionsStore ,
@@ -26,21 +27,9 @@ import {
2627 type ModelFilter ,
2728} from './view-options-store' ;
2829
29- const CHANNEL_FILTER_OPTIONS : Array < { value : ChannelFilter ; label : string } > = [
30- { value : 'all' , label : 'All channels' } ,
31- { value : 'enabled' , label : 'Enabled only' } ,
32- { value : 'disabled' , label : 'Disabled only' } ,
33- ] ;
34- const GROUP_FILTER_OPTIONS : Array < { value : GroupFilter ; label : string } > = [
35- { value : 'all' , label : 'All groups' } ,
36- { value : 'with-members' , label : 'With members' } ,
37- { value : 'empty' , label : 'Empty groups' } ,
38- ] ;
39- const MODEL_FILTER_OPTIONS : Array < { value : ModelFilter ; label : string } > = [
40- { value : 'all' , label : 'All models' } ,
41- { value : 'priced' , label : 'Priced only' } ,
42- { value : 'free' , label : 'Free only' } ,
43- ] ;
30+ const CHANNEL_FILTER_OPTIONS : ChannelFilter [ ] = [ 'all' , 'enabled' , 'disabled' ] ;
31+ const GROUP_FILTER_OPTIONS : GroupFilter [ ] = [ 'all' , 'with-members' , 'empty' ] ;
32+ const MODEL_FILTER_OPTIONS : ModelFilter [ ] = [ 'all' , 'priced' , 'free' ] ;
4433
4534function isToolbarPage ( item : NavItem ) : item is ToolbarPage {
4635 return ( TOOLBAR_PAGES as readonly NavItem [ ] ) . includes ( item ) ;
@@ -58,6 +47,7 @@ function CreateDialogContent({ activeItem }: { activeItem: ToolbarPage }) {
5847}
5948
6049export function Toolbar ( ) {
50+ const t = useTranslations ( 'toolbar' ) ;
6151 const { activeItem } = useNavStore ( ) ;
6252 const toolbarItem = isToolbarPage ( activeItem ) ? activeItem : null ;
6353 const searchTerm = useSearchStore ( ( s ) => ( toolbarItem ? s . searchTerms [ toolbarItem ] || '' : '' ) ) ;
@@ -77,11 +67,36 @@ export function Toolbar() {
7767
7868 if ( ! toolbarItem ) return null ;
7969
70+ const channelFilterLabelKeys : Record < ChannelFilter , string > = {
71+ all : 'popover.filter.channel.all' ,
72+ enabled : 'popover.filter.channel.enabled' ,
73+ disabled : 'popover.filter.channel.disabled' ,
74+ } ;
75+ const groupFilterLabelKeys : Record < GroupFilter , string > = {
76+ all : 'popover.filter.group.all' ,
77+ 'with-members' : 'popover.filter.group.withMembers' ,
78+ empty : 'popover.filter.group.empty' ,
79+ } ;
80+ const modelFilterLabelKeys : Record < ModelFilter , string > = {
81+ all : 'popover.filter.model.all' ,
82+ priced : 'popover.filter.model.priced' ,
83+ free : 'popover.filter.model.free' ,
84+ } ;
85+
8086 const filterOptions = toolbarItem === 'channel'
81- ? CHANNEL_FILTER_OPTIONS
87+ ? CHANNEL_FILTER_OPTIONS . map ( ( value ) => ( {
88+ value,
89+ label : t ( channelFilterLabelKeys [ value ] ) ,
90+ } ) )
8291 : toolbarItem === 'group'
83- ? GROUP_FILTER_OPTIONS
84- : MODEL_FILTER_OPTIONS ;
92+ ? GROUP_FILTER_OPTIONS . map ( ( value ) => ( {
93+ value,
94+ label : t ( groupFilterLabelKeys [ value ] ) ,
95+ } ) )
96+ : MODEL_FILTER_OPTIONS . map ( ( value ) => ( {
97+ value,
98+ label : t ( modelFilterLabelKeys [ value ] ) ,
99+ } ) ) ;
85100
86101 const activeFilter = toolbarItem === 'channel'
87102 ? channelFilter
@@ -154,7 +169,7 @@ export function Toolbar() {
154169 < PopoverTrigger asChild >
155170 < button
156171 type = "button"
157- aria-label = "View options"
172+ aria-label = { t ( 'popover.ariaLabel' ) }
158173 className = { buttonVariants ( {
159174 variant : 'ghost' ,
160175 size : 'icon' ,
@@ -172,7 +187,7 @@ export function Toolbar() {
172187 >
173188 < div className = "grid gap-3" >
174189 < div className = "grid gap-2" >
175- < p className = "text-xs font-medium text-muted-foreground" > Layout </ p >
190+ < p className = "text-xs font-medium text-muted-foreground" > { t ( 'popover.layout' ) } </ p >
176191 < div className = "grid grid-cols-2 gap-2" >
177192 < button
178193 type = "button"
@@ -185,7 +200,7 @@ export function Toolbar() {
185200 ) }
186201 >
187202 < LayoutGrid className = "size-3.5" />
188- Grid
203+ { t ( 'popover.grid' ) }
189204 </ button >
190205 < button
191206 type = "button"
@@ -198,13 +213,13 @@ export function Toolbar() {
198213 ) }
199214 >
200215 < List className = "size-3.5" />
201- List
216+ { t ( 'popover.list' ) }
202217 </ button >
203218 </ div >
204219 </ div >
205220
206221 < div className = "grid gap-2" >
207- < p className = "text-xs font-medium text-muted-foreground" > Sort </ p >
222+ < p className = "text-xs font-medium text-muted-foreground" > { t ( 'popover.sort' ) } </ p >
208223 < div className = "grid grid-cols-2 gap-2" >
209224 < button
210225 type = "button"
@@ -217,7 +232,7 @@ export function Toolbar() {
217232 ) }
218233 >
219234 < ArrowDownUp className = "size-3.5" />
220- Asc
235+ { t ( 'popover.asc' ) }
221236 </ button >
222237 < button
223238 type = "button"
@@ -230,13 +245,13 @@ export function Toolbar() {
230245 ) }
231246 >
232247 < ArrowDownUp className = "size-3.5 rotate-180" />
233- Desc
248+ { t ( 'popover.desc' ) }
234249 </ button >
235250 </ div >
236251 </ div >
237252
238253 < div className = "grid gap-2" >
239- < p className = "text-xs font-medium text-muted-foreground" > Filter </ p >
254+ < p className = "text-xs font-medium text-muted-foreground" > { t ( 'popover.filter.title' ) } </ p >
240255 < div className = "grid gap-2" >
241256 { filterOptions . map ( ( option ) => (
242257 < button
0 commit comments