@@ -50,9 +50,9 @@ public function __construct(
5050 $ this ->translator = $ translator ;
5151 }
5252
53- public function getSynonymPlaceholders (): array
53+ public function getSynonymPlaceholders (string $ locale ): array
5454 {
55- return $ this ->cache ->get ('partdb_synonym_placeholders ' , function (ItemInterface $ item ) {
55+ return $ this ->cache ->get ('partdb_synonym_placeholders ' . ' _ ' . $ locale , function (ItemInterface $ item) use ( $ locale ) {
5656 $ item ->tag ('synonyms ' );
5757
5858
@@ -62,12 +62,12 @@ public function getSynonymPlaceholders(): array
6262 foreach (ElementTypes::cases () as $ elementType ) {
6363 //Versions with capitalized first letter
6464 $ capitalized = ucfirst ($ elementType ->value ); //We have only ASCII element type values, so this is sufficient
65- $ placeholders ['[ ' . $ capitalized . '] ' ] = $ this ->typeNameGenerator ->typeLabel ($ elementType );
66- $ placeholders ['[[ ' . $ capitalized . ']] ' ] = $ this ->typeNameGenerator ->typeLabelPlural ($ elementType );
65+ $ placeholders ['[ ' . $ capitalized . '] ' ] = $ this ->typeNameGenerator ->typeLabel ($ elementType, $ locale );
66+ $ placeholders ['[[ ' . $ capitalized . ']] ' ] = $ this ->typeNameGenerator ->typeLabelPlural ($ elementType, $ locale );
6767
6868 //And we have lowercase versions for both
69- $ placeholders ['[ ' . $ elementType ->value . '] ' ] = mb_strtolower ($ this ->typeNameGenerator ->typeLabel ($ elementType ));
70- $ placeholders ['[[ ' . $ elementType ->value . ']] ' ] = mb_strtolower ($ this ->typeNameGenerator ->typeLabelPlural ($ elementType ));
69+ $ placeholders ['[ ' . $ elementType ->value . '] ' ] = mb_strtolower ($ this ->typeNameGenerator ->typeLabel ($ elementType, $ locale ));
70+ $ placeholders ['[[ ' . $ elementType ->value . ']] ' ] = mb_strtolower ($ this ->typeNameGenerator ->typeLabelPlural ($ elementType, $ locale ));
7171 }
7272
7373 return $ placeholders ;
@@ -82,7 +82,7 @@ public function __invoke(RequestEvent $event): void
8282 }
8383
8484 //Register all placeholders for synonyms
85- $ placeholders = $ this ->getSynonymPlaceholders ();
85+ $ placeholders = $ this ->getSynonymPlaceholders ($ event -> getRequest ()-> getLocale () );
8686 foreach ($ placeholders as $ key => $ value ) {
8787 $ this ->translator ->addGlobalParameter ($ key , $ value );
8888 }
0 commit comments