1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
if (! function_exists('country')) { |
4
|
|
|
/** |
5
|
|
|
* Get a localized country name. |
6
|
|
|
* |
7
|
|
|
* @param string|null $countryCode |
8
|
|
|
* @return \Propaganistas\LaravelIntl\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 \Propaganistas\LaravelIntl\Currency|string |
25
|
|
|
*/ |
26
|
|
|
function currency() |
27
|
|
|
{ |
28
|
6 |
|
$arguments = func_get_args(); |
29
|
|
|
|
30
|
6 |
|
if (count($arguments) === 0) { |
31
|
6 |
|
return app('intl.currency'); |
32
|
|
|
} |
33
|
|
|
|
34
|
3 |
|
if (count($arguments) > 0 && is_numeric($arguments[0])) { |
35
|
3 |
|
return app('intl.currency')->format(...$arguments); |
36
|
|
|
} |
37
|
|
|
|
38
|
3 |
|
return 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 \Propaganistas\LaravelIntl\Language|string |
62
|
|
|
*/ |
63
|
|
|
function language($langCode = null) |
64
|
|
|
{ |
65
|
6 |
|
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 formatted localized number. |
76
|
|
|
* |
77
|
|
|
* @param null $number |
78
|
|
|
* @param array $options |
79
|
|
|
* @return \Propaganistas\LaravelIntl\Number|string |
80
|
|
|
*/ |
81
|
|
|
function number($number = null, $options = []) |
82
|
|
|
{ |
83
|
6 |
|
if (is_null($number)) { |
84
|
6 |
|
return app('intl.number'); |
85
|
|
|
} |
86
|
|
|
|
87
|
3 |
|
return app('intl.number')->format($number, $options); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|