03.12.2015 Views

laravel4cookbook

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Multisites 216<br />

10 $cheese = trans("routes.cheese");<br />

11 $create = trans("routes.create");<br />

12 $update = trans("routes.update");<br />

13 $delete = trans("routes.delete");<br />

14<br />

15 Route::any($cheese . "/" . $create,<br />

16 function() use ($cheese, $create)<br />

17 {<br />

18 return $cheese . "/" . $create;<br />

19 });<br />

20<br />

21 Route::any($cheese . "/" . $update,<br />

22 function() use ($cheese, $update)<br />

23 {<br />

24 return $cheese . "/" . $update;<br />

25 });<br />

26<br />

27 Route::any($cheese . "/" . $delete,<br />

28 function() use ($cheese, $delete)<br />

29 {<br />

30 return $cheese . "/" . $delete;<br />

31 });<br />

32 }<br />

.<br />

This was extracted from app/routes.php.<br />

We hard-code the locale names because it’s the most efficient way to return them in the routes file.<br />

Routes are determined on each application request, so we dare not do a file lookup…<br />

What this is basically doing is looping through the locales and creating routes based on translated<br />

phrases specific to the locale that’s been set. It’s a simple, but effective, mechanism for implementing<br />

multi-language routes.<br />

If you would like to review the registered routes (for each language), you can run the following<br />

command:<br />

1 php artisan routes

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!