forked from ARCANEDEV/Localization
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.php
32 lines (29 loc) · 831 Bytes
/
helpers.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
if ( ! function_exists('localization')) {
/**
* Get the Localization instance.
*
* @return Arcanedev\Localization\Contracts\Localization
*/
function localization()
{
return app(Arcanedev\Localization\Contracts\Localization::class);
}
}
if ( ! function_exists('localized_route')) {
/**
* Get a localized URL with a given trans route name.
*
* @param string $transRoute
* @param array $attributes
* @param string|null $locale
*
* @return string
*/
function localized_route($transRoute, array $attributes = [], $locale = null)
{
if (is_null($locale))
$locale = localization()->getCurrentLocale();
return localization()->getUrlFromRouteName($locale, $transRoute, $attributes);
}
}