Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
bc77d7c0 TO |
6 | | This work is published under the GNU AGPLv3 license with some | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
6a488035 TO |
16 | * |
17 | * Convenience class for PHP-Gettext compatibility. | |
18 | */ | |
19 | class CRM_Core_I18n_NativeGettext { | |
518fa0ee | 20 | |
a0ee3941 EM |
21 | /** |
22 | * @param $string | |
23 | * | |
24 | * @return string | |
25 | */ | |
00be9182 | 26 | public function translate($string) { |
6a488035 TO |
27 | return gettext($string); |
28 | } | |
29 | ||
30 | /** | |
31 | * Based on php-gettext, since native gettext does not support this as is. | |
7a9ab499 EM |
32 | * |
33 | * @param $context | |
34 | * @param $text | |
35 | * | |
36 | * @return string | |
6a488035 | 37 | */ |
00be9182 | 38 | public function pgettext($context, $text) { |
6a488035 TO |
39 | $key = $context . chr(4) . $text; |
40 | $ret = $this->translate($key); | |
41 | ||
42 | if (strpos($ret, "\004") !== FALSE) { | |
43 | return $text; | |
44 | } | |
45 | else { | |
46 | return $ret; | |
47 | } | |
48 | } | |
49 | ||
a0ee3941 EM |
50 | /** |
51 | * @param $text | |
52 | * @param $plural | |
53 | * @param $count | |
54 | * | |
55 | * @return string | |
56 | */ | |
00be9182 | 57 | public function ngettext($text, $plural, $count) { |
6a488035 TO |
58 | return ngettext($text, $plural, $count); |
59 | } | |
96025800 | 60 | |
6a488035 | 61 | } |