@@ -29,8 +29,6 @@ function current_path_locale($page): string
2929{
3030 $ path = trim ($ page ->getPath (), '/ ' );
3131
32- $ default_locale = $ page ->defaultLocale ?? packageDefaultLocale ();
33-
3432 /**
3533 * - [a-z]{2,3} language code
3634 * - [A-Z]{2} region code
@@ -41,7 +39,7 @@ function current_path_locale($page): string
4139
4240 preg_match ($ locale_regex , $ path , $ matches );
4341
44- return $ matches ['locale ' ] ?? $ default_locale ;
42+ return $ matches ['locale ' ] ?? packageDefaultLocale () ;
4543}
4644
4745/**
@@ -56,12 +54,12 @@ function translate_path($page, ?string $target_locale = null): string
5654 $ current_locale = current_path_locale ($ page );
5755
5856 $ partial_path = match (true ) {
59- $ current_locale === $ page-> defaultLocale => $ page ->getPath (),
57+ $ current_locale === packageDefaultLocale ( $ page) => $ page ->getPath (),
6058 default => substr ($ page ->getPath (), strlen ($ current_locale ) + 1 ),
6159 };
6260
6361 return match (true ) {
64- $ target_locale === $ page-> defaultLocale => "{$ partial_path }" ,
62+ $ target_locale === packageDefaultLocale ( $ page) => "{$ partial_path }" ,
6563 default => "/ {$ target_locale }{$ partial_path }" ,
6664 };
6765}
@@ -89,7 +87,7 @@ function locale_path($page, string $partial_path, ?string $target_locale = null)
8987 $ partial_path = '/ ' .trim ($ partial_path , '/ ' );
9088
9189 return match (true ) {
92- $ target_locale === $ page-> defaultLocale => $ partial_path ,
90+ $ target_locale === packageDefaultLocale ( $ page) => $ partial_path ,
9391 default => "/ {$ target_locale }{$ partial_path }"
9492 };
9593}
0 commit comments