|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
if (!function_exists('country')) { |
|
4
|
|
|
/** |
|
5
|
|
|
* Get a localized country name. |
|
6
|
|
|
* |
|
7
|
|
|
* @param string|null $countryCode |
|
8
|
|
|
* @return \CommerceGuys\Intl\Country\Country|string |
|
9
|
|
|
*/ |
|
10
|
|
|
function country($countryCode = null) |
|
11
|
|
|
{ |
|
12
|
6 |
|
if (is_null($countryCode)) { |
|
13
|
6 |
|
return app('intl.country'); |
|
14
|
|
|
} |
|
15
|
|
|
|
|
16
|
3 |
|
return app('intl.country')->name($countryCode); |
|
17
|
|
|
} |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
if (!function_exists('currency')) { |
|
21
|
|
|
/** |
|
22
|
|
|
* Get a localized currency or currency amount. |
|
23
|
|
|
* |
|
24
|
|
|
* @return \CommerceGuys\Intl\Currency\Currency|string |
|
25
|
|
|
*/ |
|
26
|
|
|
function currency() |
|
27
|
|
|
{ |
|
28
|
9 |
|
$arguments = func_get_args(); |
|
29
|
|
|
|
|
30
|
9 |
|
if (count($arguments) === 0) { |
|
31
|
9 |
|
return app('intl.currency'); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
3 |
|
if (count($arguments) > 0 && is_numeric($arguments[0])) { |
|
35
|
3 |
|
return call_user_func_array([app('intl.currency'), 'format'], $arguments); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
3 |
|
return call_user_func_array([app('intl.currency'), 'name'], $arguments); |
|
39
|
|
|
} |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
if (!function_exists('carbon')) { |
|
43
|
|
|
/** |
|
44
|
|
|
* Get a localized Carbon instance. |
|
45
|
|
|
* |
|
46
|
|
|
* @param string $time |
|
47
|
|
|
* @param string|DateTimeZone $timezone |
|
48
|
|
|
* @return \Jenssegers\Date\Date|string |
|
49
|
|
|
*/ |
|
50
|
|
|
function carbon($time = null, $timezone = null) |
|
51
|
|
|
{ |
|
52
|
6 |
|
return app('intl.date')->make($time, $timezone); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
if (!function_exists('language')) { |
|
57
|
|
|
/** |
|
58
|
|
|
* Get a localized language name. |
|
59
|
|
|
* |
|
60
|
|
|
* @param string|null $langCode |
|
61
|
|
|
* @return \CommerceGuys\Intl\Language\Language|string |
|
62
|
|
|
*/ |
|
63
|
|
|
function language($langCode = null) |
|
64
|
|
|
{ |
|
65
|
8 |
|
if (is_null($langCode)) { |
|
66
|
6 |
|
return app('intl.language'); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
3 |
|
return app('intl.language')->name($langCode); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
if (!function_exists('number')) { |
|
74
|
|
|
/** |
|
75
|
|
|
* Get a localized value. |
|
76
|
|
|
* |
|
77
|
|
|
* @param int|float|string|null $amount |
|
78
|
|
|
* @return \CommerceGuys\Intl\NumberFormat\NumberFormat|string |
|
79
|
|
|
*/ |
|
80
|
|
|
function number($amount = null) |
|
81
|
|
|
{ |
|
82
|
6 |
|
if (is_null($amount)) { |
|
83
|
6 |
|
return app('intl.number'); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
3 |
|
if (!is_numeric($amount)) { |
|
87
|
|
|
return app('intl.number')->get($amount); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
3 |
|
return app('intl.number')->format($amount); |
|
91
|
|
|
} |
|
92
|
|
|
} |