forked from ARCANEDEV/Localization
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.php
36 lines (31 loc) · 890 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
33
34
35
36
<?php
declare(strict_types=1);
use Arcanedev\Localization\Contracts\Localization;
if ( ! function_exists('localization')) {
/**
* Get the Localization instance.
*
* @return Arcanedev\Localization\Contracts\Localization
*/
function localization(): Localization
{
return app(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);
}
}