|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license MIT, http://opensource.org/licenses/MIT |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2017 |
|
6
|
|
|
* @package laravel |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
if (! function_exists('airoute')) { |
|
11
|
|
|
/** |
|
12
|
|
|
* Generate the URL to a named route. |
|
13
|
|
|
* |
|
14
|
|
|
* @param array|string $name |
|
15
|
|
|
* @param mixed $parameters |
|
16
|
|
|
* @param bool $absolute |
|
17
|
|
|
* @return string |
|
18
|
|
|
*/ |
|
19
|
|
|
function airoute( $name, $parameters = [], $absolute = true ) |
|
20
|
|
|
{ |
|
21
|
|
|
if( $current = Route::current() ) |
|
22
|
|
|
{ |
|
23
|
|
|
$parameters['site'] = $current->parameter( 'site', Request::get( 'site' ) ); |
|
24
|
|
|
$parameters['locale'] = $current->parameter( 'locale', Request::get( 'locale' ) ); |
|
25
|
|
|
$parameters['currency'] = $current->parameter( 'currency', Request::get( 'currency' ) ); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
return app('url')->route( $name, array_filter( $parameters ), $absolute ); |
|
|
|
|
|
|
29
|
|
|
} |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
if( !function_exists( 'aiconfig' ) ) |
|
34
|
|
|
{ |
|
35
|
|
|
/** |
|
36
|
|
|
* Returns the configuration setting for the given key |
|
37
|
|
|
* |
|
38
|
|
|
* @param string $key Configuration key |
|
39
|
|
|
* @param mixed $default Default value if the configuration key isn't found |
|
40
|
|
|
* @return mixed Configuration value |
|
41
|
|
|
*/ |
|
42
|
|
|
function aiconfig( $key, $default = null ) |
|
43
|
|
|
{ |
|
44
|
|
|
return app( 'aimeos.config' )->get()->get( $key, $default ); |
|
45
|
|
|
} |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
|
|
49
|
|
|
if( !function_exists( 'aitrans' ) ) |
|
50
|
|
|
{ |
|
51
|
|
|
/** |
|
52
|
|
|
* Translates the given message |
|
53
|
|
|
* |
|
54
|
|
|
* @param string $singular Message to translate |
|
55
|
|
|
* @param array $params List of paramters for replacing the placeholders in that order |
|
56
|
|
|
* @param string $domain Translation domain |
|
57
|
|
|
* @param string $locale ISO language code, maybe combine with ISO currency code, e.g. "en_US" |
|
58
|
|
|
* @return string Translated string |
|
59
|
|
|
*/ |
|
60
|
|
|
function aitrans( $singular, array $params = array(), $domain = 'client', $locale = null ) |
|
61
|
|
|
{ |
|
62
|
|
|
$i18n = app( 'aimeos.context' )->get()->getI18n( $locale ); |
|
63
|
|
|
|
|
64
|
|
|
return vsprintf( $i18n->dt( $domain, $singular ), $params ); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
|
|
69
|
|
|
if( !function_exists( 'aitransplural' ) ) |
|
70
|
|
|
{ |
|
71
|
|
|
/** |
|
72
|
|
|
* Translates the given messages based on the number |
|
73
|
|
|
* |
|
74
|
|
|
* @param string $singular Message to translate |
|
75
|
|
|
* @param string $plural Message for plural translations |
|
76
|
|
|
* @param integer $number Count of items to chose the correct plural translation |
|
77
|
|
|
* @param array $params List of paramters for replacing the placeholders in that order |
|
78
|
|
|
* @param string $domain Translation domain |
|
79
|
|
|
* @param string $locale ISO language code, maybe combine with ISO currency code, e.g. "en_US" |
|
80
|
|
|
* @return string Translated string |
|
81
|
|
|
*/ |
|
82
|
|
|
function aitransplural( $singular, $plural, $number, array $params = array(), $domain = 'client', $locale = null ) |
|
83
|
|
|
{ |
|
84
|
|
|
$i18n = app( 'aimeos.context' )->get()->getI18n( $locale ); |
|
85
|
|
|
|
|
86
|
|
|
return vsprintf( $i18n->dn( $domain, $singular, $plural, $number ), $params ); |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|