8
8
use Session ;
9
9
use Cookie ;
10
10
use App ;
11
- use View ;
12
11
use Config ;
13
12
14
13
class LaravelLocalization
@@ -65,7 +64,7 @@ class LaravelLocalization
65
64
/**
66
65
* Name of the translation key of the current route, it is used for url translations
67
66
*
68
- * @var array|string
67
+ * @var array
69
68
*/
70
69
protected $ routesNames = array ();
71
70
@@ -170,7 +169,7 @@ public function setLocale($locale = null)
170
169
* @param boolean $abbr Should languages be abbreviate to their locale codes?
171
170
* @param string $customView Which template should the language bar have?
172
171
*
173
- * @return string Returns an html view with a language bar
172
+ * @return \Illuminate\View\View Returns an html view with a language bar
174
173
*
175
174
* @deprecated will be removed in v1.0 please see updated readme for details on making your own language bar template.
176
175
*/
@@ -344,10 +343,10 @@ public function getLocalizedURL($locale = null, $url = null)
344
343
* Returns an URL adapted to the route name and the locale given
345
344
*
346
345
* @param string $locale Locale to adapt
347
- * @param string $transKeyName Translation key name of the url to adapt
346
+ * @param string $transKeysNames Translation key name of the url to adapt
348
347
* @param array $attributes Attributes for the route (only needed if transKeyName needs them)
349
348
*
350
- * @return string|boolean URL translated
349
+ * @return string|false URL translated
351
350
*/
352
351
public function getURLFromRouteNameTranslated ($ locale , $ transKeysNames = array (), $ attributes = array ())
353
352
{
@@ -718,17 +717,32 @@ public function getTranslatedRoutes()
718
717
719
718
/**
720
719
* Set current route name
721
- * @param string $name current route name
720
+ * @param string|array $routeNames current route name
722
721
*/
723
- public function setRouteName ($ name , $ add = false )
722
+ public function setRouteName ($ routeNames , $ add = false )
724
723
{
725
724
if ($ add )
726
725
{
727
- $ this ->routesNames [] = $ name ;
726
+ if (is_string ($ routeNames ))
727
+ {
728
+ $ this ->routesNames [] = $ routeNames ;
729
+ }
730
+ else
731
+ {
732
+ $ this ->routesNames = array_merge ($ this ->routesNames , $ routeNames );
733
+ }
728
734
}
729
735
else
730
736
{
731
- $ this ->routesNames = $ name ;
737
+ if (is_string ($ routeNames ))
738
+ {
739
+ $ this ->routesNames = [];
740
+ $ this ->routesNames [] = $ routeNames ;
741
+ }
742
+ else
743
+ {
744
+ $ this ->routesNames = $ routeNames ;
745
+ }
732
746
}
733
747
}
734
748
@@ -753,7 +767,7 @@ public function transRoute($routeName)
753
767
*
754
768
* @param string $path Path to get the key translated
755
769
*
756
- * @return string|boolean Key for translation
770
+ * @return arrays Keys for translation
757
771
*/
758
772
public function getRouteNameFromAPath ($ path )
759
773
{
@@ -766,16 +780,15 @@ public function getRouteNameFromAPath($path)
766
780
$ path = trim ($ path ,"/ " );
767
781
$ routesNames = [];
768
782
769
-
770
783
foreach ($ this ->translatedRoutes as $ route )
771
784
{
772
785
if ($ this ->translator ->trans ($ route ) == $ path )
773
786
{
774
- return $ route ;
787
+ $ routesNames [] = $ route ;
775
788
}
776
789
}
777
790
778
- return False ;
791
+ return $ routesNames ;
779
792
}
780
793
781
794
@@ -955,8 +968,3 @@ public function negotiateLanguage()
955
968
}
956
969
957
970
}
958
-
959
- class UnsupportedLocaleException extends Exception
960
- {
961
-
962
- }
0 commit comments