@@ -27,6 +27,11 @@ public function __construct(
2727 //
2828 }
2929
30+ public function getJsonNamespace (): string
31+ {
32+ return static ::JSON_NAMESPACE ;
33+ }
34+
3035 /**
3136 * @return string[]
3237 */
@@ -54,7 +59,7 @@ public function getNamespaces(string $locale): array
5459
5560 public function getTranslations (
5661 string $ locale ,
57- ?string $ namespace = null
62+ ?string $ namespace
5863 ): PhpTranslations |JsonTranslations {
5964 $ namespace ??= static ::JSON_NAMESPACE ;
6065
@@ -76,7 +81,7 @@ public function getTranslations(
7681
7782 protected function getTranslationsFileContent (
7883 string $ locale ,
79- ?string $ namespace = null
84+ ?string $ namespace
8085 ): ?string {
8186 $ namespace ??= static ::JSON_NAMESPACE ;
8287
@@ -95,8 +100,10 @@ protected function getTranslationsFileContent(
95100 public function getMissingTranslations (
96101 string $ source ,
97102 string $ target ,
98- string $ namespace ,
103+ ? string $ namespace ,
99104 ): Collection {
105+ $ namespace ??= static ::JSON_NAMESPACE ;
106+
100107 return $ this
101108 ->getTranslations ($ source , $ namespace )
102109 ->diffTranslationsKeys (
@@ -135,11 +142,12 @@ public function getAllMissingTranslations(
135142 */
136143 public function getDeadTranslations (
137144 string $ locale ,
138- string $ namespace ,
145+ ? string $ namespace ,
139146 ?SearchCodeServiceInterface $ service = null ,
140147 ?Closure $ progress = null ,
141148 ?array $ ignore = null ,
142149 ): Collection {
150+ $ namespace ??= static ::JSON_NAMESPACE ;
143151 $ ignoredTranslations = $ ignore ?? config ('translator.searchcode.ignored_translations ' , []);
144152
145153 $ translationsKeys = $ this
@@ -231,9 +239,10 @@ public function getUsedTranslationsByFiles(
231239
232240 public function setTranslations (
233241 string $ locale ,
234- string $ namespace ,
242+ ? string $ namespace ,
235243 array $ values
236244 ): PhpTranslations |JsonTranslations {
245+ $ namespace ??= static ::JSON_NAMESPACE ;
237246
238247 if (empty ($ values )) {
239248 return $ this ->getNewTranslationsCollection ($ namespace );
@@ -258,10 +267,12 @@ function (PhpTranslations|JsonTranslations $translations) use ($values) {
258267
259268 public function setTranslation (
260269 string $ locale ,
261- string $ namespace ,
270+ ? string $ namespace ,
262271 string $ key ,
263272 mixed $ value ,
264273 ): PhpTranslations |JsonTranslations {
274+ $ namespace ??= static ::JSON_NAMESPACE ;
275+
265276 return $ this ->setTranslations ($ locale , $ namespace , [
266277 $ key => $ value ,
267278 ]);
@@ -270,10 +281,11 @@ public function setTranslation(
270281 public function translateTranslations (
271282 string $ source ,
272283 string $ target ,
273- string $ namespace ,
284+ ? string $ namespace ,
274285 array $ keys ,
275286 ?TranslateServiceInterface $ service = null ,
276287 ): PhpTranslations |JsonTranslations {
288+ $ namespace ??= static ::JSON_NAMESPACE ;
277289 $ service = $ service ?? $ this ->translateService ;
278290
279291 if (! $ service ) {
@@ -316,10 +328,12 @@ function (PhpTranslations|JsonTranslations $translations) use ($source, $target,
316328 public function translateTranslation (
317329 string $ source ,
318330 string $ target ,
319- string $ namespace ,
331+ ? string $ namespace ,
320332 string $ key ,
321333 ?TranslateServiceInterface $ service = null ,
322334 ): PhpTranslations |JsonTranslations {
335+ $ namespace ??= static ::JSON_NAMESPACE ;
336+
323337 return $ this ->translateTranslations (
324338 $ source ,
325339 $ target ,
@@ -331,10 +345,11 @@ public function translateTranslation(
331345
332346 public function proofreadTranslations (
333347 string $ locale ,
334- string $ namespace ,
348+ ? string $ namespace ,
335349 array $ keys ,
336350 ?ProofreadServiceInterface $ service = null ,
337351 ): PhpTranslations |JsonTranslations {
352+ $ namespace ??= static ::JSON_NAMESPACE ;
338353 $ service = $ service ?? $ this ->proofreadService ;
339354
340355 if (! $ service ) {
@@ -373,10 +388,12 @@ function (PhpTranslations|JsonTranslations $translations) use ($service, $keys)
373388
374389 public function proofreadTranslation (
375390 string $ locale ,
376- string $ namespace ,
391+ ? string $ namespace ,
377392 string $ key ,
378393 ?ProofreadServiceInterface $ service = null ,
379394 ): PhpTranslations |JsonTranslations {
395+ $ namespace ??= static ::JSON_NAMESPACE ;
396+
380397 return $ this ->proofreadTranslations (
381398 $ locale ,
382399 $ namespace ,
@@ -387,9 +404,11 @@ public function proofreadTranslation(
387404
388405 public function deleteTranslations (
389406 string $ locale ,
390- string $ namespace ,
407+ ? string $ namespace ,
391408 array $ keys ,
392409 ): PhpTranslations |JsonTranslations {
410+ $ namespace ??= static ::JSON_NAMESPACE ;
411+
393412 return $ this ->transformTranslations (
394413 $ locale ,
395414 $ namespace ,
@@ -403,18 +422,24 @@ function (PhpTranslations|JsonTranslations $translations) use ($keys) {
403422
404423 public function deleteTranslation (
405424 string $ locale ,
406- string $ namespace ,
425+ ? string $ namespace ,
407426 string $ key ,
408427 ): PhpTranslations |JsonTranslations {
428+ $ namespace ??= static ::JSON_NAMESPACE ;
429+
409430 return $ this ->deleteTranslations (
410431 $ locale ,
411432 $ namespace ,
412433 [$ key ]
413434 );
414435 }
415436
416- public function sortTranslations (string $ locale , string $ namespace ): PhpTranslations |JsonTranslations
417- {
437+ public function sortTranslations (
438+ string $ locale ,
439+ ?string $ namespace
440+ ): PhpTranslations |JsonTranslations {
441+ $ namespace ??= static ::JSON_NAMESPACE ;
442+
418443 return $ this ->transformTranslations (
419444 $ locale ,
420445 $ namespace ,
@@ -443,9 +468,11 @@ public function sortAllTranslations(): Collection
443468 */
444469 public function transformTranslations (
445470 string $ locale ,
446- string $ namespace ,
471+ ? string $ namespace ,
447472 Closure $ callback ,
448473 ): PhpTranslations |JsonTranslations {
474+ $ namespace ??= static ::JSON_NAMESPACE ;
475+
449476 $ translations = $ this ->getTranslations ($ locale , $ namespace );
450477 $ translations = $ callback ($ translations );
451478
@@ -458,9 +485,11 @@ public function transformTranslations(
458485
459486 public function saveTranslations (
460487 string $ locale ,
461- string $ namespace ,
488+ ? string $ namespace ,
462489 PhpTranslations |JsonTranslations $ translations ,
463490 ): bool {
491+ $ namespace ??= static ::JSON_NAMESPACE ;
492+
464493 return $ this ->storage ->put (
465494 $ this ->getTranslationsPath ($ locale , $ namespace ),
466495 $ translations ->toFile ()
@@ -469,7 +498,7 @@ public function saveTranslations(
469498
470499 public function getTranslationsPath (
471500 string $ locale ,
472- ?string $ namespace = null
501+ ?string $ namespace
473502 ): string {
474503 $ namespace ??= static ::JSON_NAMESPACE ;
475504
@@ -480,8 +509,10 @@ public function getTranslationsPath(
480509 }
481510
482511 public function getNewTranslationsCollection (
483- string $ namespace
512+ ? string $ namespace
484513 ): PhpTranslations |JsonTranslations {
514+ $ namespace ??= static ::JSON_NAMESPACE ;
515+
485516 return match ($ namespace ) {
486517 static ::JSON_NAMESPACE => new JsonTranslations ,
487518 default => new PhpTranslations ,
0 commit comments