|
1
|
|
|
<?php |
|
2
|
|
|
// @codeCoverageIgnoreStart |
|
3
|
|
|
defined('BASEPATH') || exit('No direct script access allowed'); |
|
4
|
|
|
// @codeCoverageIgnoreEnd |
|
5
|
|
|
/** |
|
6
|
|
|
* CodeIgniter Gettext Helpers |
|
7
|
|
|
* |
|
8
|
|
|
* @package CodeIgniter |
|
9
|
|
|
* @subpackage Helpers |
|
10
|
|
|
* @category Gettext |
|
11
|
|
|
* @author Joël Gaujard <[email protected]> |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
if (!function_exists('__')) { |
|
15
|
|
|
/** |
|
16
|
|
|
* Search translation to simple expression |
|
17
|
|
|
* |
|
18
|
|
|
* @param string $expression |
|
19
|
|
|
* @param string $domain |
|
20
|
|
|
* @param string $category |
|
21
|
|
|
* @return string |
|
22
|
|
|
*/ |
|
23
|
|
|
function __($expression, $domain=null, $category=null) |
|
24
|
|
|
{ |
|
25
|
44 |
|
if (!empty($domain)) { |
|
26
|
24 |
|
(new \Gettext())->changeDomain($domain); |
|
27
|
|
|
|
|
28
|
24 |
|
if (!empty($category)) { |
|
29
|
16 |
|
$category = is_int($category) ? $category : constant($category); |
|
30
|
16 |
|
return (dcgettext($domain, $expression, $category)); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
12 |
|
return (dgettext($domain, $expression)); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
24 |
|
return (gettext($expression)); |
|
37
|
|
|
|
|
38
|
|
|
} |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
if (!function_exists('_e')) { |
|
42
|
|
|
/** |
|
43
|
|
|
* Display a simple expression |
|
44
|
|
|
* |
|
45
|
|
|
* @param string $expression |
|
46
|
|
|
* @param string $domain |
|
47
|
|
|
* @param string $category |
|
48
|
|
|
*/ |
|
49
|
|
|
function _e($expression, $domain=null, $category=null) |
|
50
|
|
|
{ |
|
51
|
28 |
|
echo (__($expression, $domain, $category)); |
|
52
|
|
|
|
|
53
|
28 |
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
if (!function_exists('_n')) { |
|
57
|
|
|
/** |
|
58
|
|
|
* Search translation to expression and its plural |
|
59
|
|
|
* |
|
60
|
|
|
* @param string $expression_singular |
|
61
|
|
|
* @param string $expression_plural |
|
62
|
|
|
* @param int $number |
|
63
|
|
|
* @param string $domain |
|
64
|
|
|
* @param string $category |
|
65
|
|
|
* @return string |
|
66
|
|
|
*/ |
|
67
|
|
|
function _n( |
|
68
|
|
|
$expression_singular, |
|
69
|
|
|
$expression_plural, |
|
70
|
|
|
$number, |
|
71
|
|
|
$domain=null, |
|
72
|
|
|
$category=null |
|
73
|
|
|
) { |
|
74
|
16 |
|
$number = (int) $number; |
|
75
|
|
|
|
|
76
|
16 |
|
if (!empty($domain)) { |
|
77
|
12 |
|
(new \Gettext())->changeDomain($domain); |
|
78
|
|
|
|
|
79
|
12 |
|
if (!empty($category)) { |
|
80
|
8 |
|
$category = is_int($category) ? $category : constant($category); |
|
81
|
8 |
|
return (dcngettext( |
|
82
|
8 |
|
$domain, |
|
83
|
8 |
|
$expression_singular, |
|
84
|
8 |
|
$expression_plural, |
|
85
|
8 |
|
$number, |
|
86
|
2 |
|
$category |
|
87
|
6 |
|
)); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
8 |
|
return (dngettext( |
|
91
|
8 |
|
$domain, |
|
92
|
8 |
|
$expression_singular, |
|
93
|
8 |
|
$expression_plural, |
|
94
|
2 |
|
$number |
|
95
|
6 |
|
)); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
8 |
|
return (ngettext($expression_singular, $expression_plural, $number)); |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/* End of file gettext_helper.php */ |
|
103
|
|
|
/* Location: ./application/helpers/gettext_helper.php */ |