1515
1616class  Translator
1717{
18+     /** 
19+      * @param  string[]  $ignoredTranslations 
20+      */ 
1821    final  public  function  __construct (
1922        public  Driver   $ driver ,
23+         public  array  $ ignoredTranslations  = [],
2024        public  ?TranslateServiceInterface   $ translateService  = null ,
2125        public  ?ProofreadServiceInterface   $ proofreadService  = null ,
2226        public  ?SearchCodeServiceInterface   $ searchcodeService  = null ,
@@ -29,6 +33,7 @@ public function driver(null|string|Driver $name): static
2933    {
3034        return  new  static (
3135            driver: $ name  instanceof  Driver ? $ name  : TranslatorServiceProvider::getDriverFromConfig ($ name ),
36+             ignoredTranslations: $ this  ->ignoredTranslations ,
3237            translateService: $ this  ->translateService ,
3338            proofreadService: $ this  ->proofreadService ,
3439            searchcodeService: $ this  ->searchcodeService ,
@@ -40,6 +45,7 @@ public function withProofreadService(ProofreadServiceInterface $service): static
4045    {
4146        return  new  static (
4247            driver: $ this  ->driver ,
48+             ignoredTranslations: $ this  ->ignoredTranslations ,
4349            translateService: $ this  ->translateService ,
4450            proofreadService: $ service ,
4551            searchcodeService: $ this  ->searchcodeService ,
@@ -51,6 +57,7 @@ public function withTranslateService(TranslateServiceInterface $service): static
5157    {
5258        return  new  static (
5359            driver: $ this  ->driver ,
60+             ignoredTranslations: $ this  ->ignoredTranslations ,
5461            translateService: $ service ,
5562            proofreadService: $ this  ->proofreadService ,
5663            searchcodeService: $ this  ->searchcodeService ,
@@ -62,6 +69,7 @@ public function withSearchcodeService(SearchCodeServiceInterface $service): stat
6269    {
6370        return  new  static (
6471            driver: $ this  ->driver ,
72+             ignoredTranslations: $ this  ->ignoredTranslations ,
6573            translateService: $ this  ->translateService ,
6674            proofreadService: $ this  ->proofreadService ,
6775            searchcodeService: $ service ,
@@ -79,9 +87,11 @@ public function getLocales(): array
7987        }
8088
8189        if  ($ validator  = TranslatorServiceProvider::getLocaleValidator ()) {
90+             $ validator  = $ validator ::make ();
91+ 
8292            return  array_values (array_filter (
8393                $ this  ->driver ->getLocales (),
84-                 fn  ($ locale ) => $ validator:: make () ->isValid ($ locale ),
94+                 fn  ($ locale ) => $ validator ->isValid ($ locale ),
8595            ));
8696        }
8797
@@ -125,9 +135,7 @@ public function getMissingTranslations(
125135        );
126136
127137        return  collect ($ keys )
128-             ->filter (function  ($ value , $ key ) use  ($ translations ) {
129-                 return  ! $ translations ->has ($ key );
130-             })
138+             ->filter (fn  ($ value , $ key ) => ! $ translations ->has ($ key ))
131139            ->all ();
132140    }
133141
@@ -140,11 +148,14 @@ public function getDeadTranslations(string $locale): Translations
140148            throw  TranslatorServiceException::missingSearchcodeService ();
141149        }
142150
143-         $ defined   = $ this  ->searchcodeService ->filesByTranslations ();
151+         $ keys   = array_keys ( $ this  ->searchcodeService ->filesByTranslations () );
144152
145153        return  $ this 
146154            ->getTranslations ($ locale )
147-             ->except (array_keys ($ defined ));
155+             ->except ([
156+                 ...$ this  ->ignoredTranslations ,
157+                 ...$ keys ,
158+             ]);
148159    }
149160
150161    public  function  getUntranslatedTranslations (
0 commit comments