@@ -15,24 +15,24 @@ class UriTranslationMacro
1515 */
1616 public static function register ()
1717 {
18- Lang::macro ('uri ' , function ($ uri , $ locale = null ) {
18+ Lang::macro ('uri ' , function ($ uri , $ locale = null , $ namespace = null ) {
1919
2020 // Attempt to translate full uri.
21- if (!Str::contains ($ uri , '{ ' ) && Lang::has ("routes. $ uri " , $ locale )) {
22- return Lang::get ("routes. $ uri " , [], $ locale );
21+ if (!Str::contains ($ uri , '{ ' ) && Lang::has (( $ namespace ? $ namespace . ' :: ' : '' ). "routes. $ uri " , $ locale )) {
22+ return Lang::get (( $ namespace ? $ namespace . ' :: ' : '' ). "routes. $ uri " , [], $ locale );
2323 }
2424
2525 // Split the URI into a Collection of segments.
2626 $ segments = new Collection (explode ('/ ' , trim ($ uri , '/ ' )));
2727
2828 // Attempt to translate each segment. If there is no translation
2929 // for a specific segment, then its original value will be used.
30- $ translations = $ segments ->map (function ($ segment ) use ($ locale ) {
31- $ translationKey = "routes. {$ segment }" ;
30+ $ translations = $ segments ->map (function ($ segment ) use ($ locale, $ namespace ) {
31+ $ translationKey = ( $ namespace ? $ namespace . ' :: ' : '' ). "routes. {$ segment }" ;
3232
3333 // If the segment is not a placeholder and the segment
3434 // has a translation, then update the segment.
35- if ( ! Str::startsWith ($ segment , '{ ' ) && Lang::has ($ translationKey , $ locale )) {
35+ if (! Str::startsWith ($ segment , '{ ' ) && Lang::has ($ translationKey , $ locale )) {
3636 $ segment = Lang::get ($ translationKey , [], $ locale );
3737 }
3838
0 commit comments