@@ -12,7 +12,7 @@ import {
1212import type { Filters } from "./PageFind" ;
1313import type { CollectionEntry } from "astro:content" ;
1414import { APPLICATION_COMPATIBILITY , GAME_AUTO_SR , GAME_COMPATIBILITY } from "../../config/enumerations" ;
15- import { t } from "i18next" ;
15+ import i18next , { t } from "i18next" ;
1616import { updateLanguage } from "../../util/updateLanguage" ;
1717
1818type FilterKey = "auto_super_resolution.compatibility" | "category" | "compatibility" ;
@@ -44,10 +44,10 @@ const FilterDropdown = ({
4444
4545} ) => {
4646 const _ = updateLanguage ( window . location ) ;
47- const filters = type === "applications" ? getApplicationFilters ( ) : getGameFilters ( ) ;
47+ const [ filters , setFilters ] = createSignal < { key : FilterKey ; name : string } [ ] > ( [ ] ) ;
4848
4949 const [ showFilters , setShowFilters ] = createSignal < Record < string , boolean > > (
50- filters . reduce (
50+ filters ( ) . reduce (
5151 ( p , f ) => ( {
5252 ...p ,
5353 [ f . key ] : false ,
@@ -70,7 +70,7 @@ const FilterDropdown = ({
7070 const handleClick = ( event : MouseEvent ) => {
7171 if ( ! ref . contains ( event . target as Node ) ) {
7272 setShowFilters (
73- filters . reduce (
73+ filters ( ) . reduce (
7474 ( p , f ) => ( {
7575 ...p ,
7676 [ f . key ] : false ,
@@ -81,8 +81,14 @@ const FilterDropdown = ({
8181 }
8282 } ;
8383
84- onMount ( ( ) => {
84+ onMount ( async ( ) => {
8585 document . addEventListener ( "click" , handleClick ) ;
86+ let filtersValues = type === "applications" ? getApplicationFilters ( ) : getGameFilters ( ) ;
87+ if ( filtersValues . some ( p => p . name . includes ( "game_filters" ) || p . name . includes ( "application_filters" ) ) ) {
88+ await i18next . reloadResources ( ) ;
89+ filtersValues = type === "applications" ? getApplicationFilters ( ) : getGameFilters ( ) ;
90+ }
91+ setFilters ( filtersValues ) ;
8692 } ) ;
8793
8894 onCleanup ( ( ) => {
@@ -108,7 +114,7 @@ const FilterDropdown = ({
108114
109115 return (
110116 < div class = " flex " ref = { ref ! } >
111- < For each = { filters } >
117+ < For each = { filters ( ) } >
112118 { ( filter ) => (
113119 < div class = "relative w-36 h-full flex-shrink-0 z-10 inline-flex text-sm font-medium text-center last:rounded-r-full first:rounded-l-full first:md:rounded-l-none border-l focus:ring-4 focus:outline-none bg-neutral-700 hover:bg-neutral-600 focus:ring-neutral-700 text-white border-neutral-600" >
114120 < button
0 commit comments