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 | * Convenience class for PHP-Gettext compatibility. |
17 | */ | |
18 | class CRM_Core_I18n_NativeGettext { | |
518fa0ee | 19 | |
a0ee3941 EM |
20 | /** |
21 | * @param $string | |
22 | * | |
23 | * @return string | |
24 | */ | |
00be9182 | 25 | public function translate($string) { |
6a488035 TO |
26 | return gettext($string); |
27 | } | |
28 | ||
29 | /** | |
30 | * Based on php-gettext, since native gettext does not support this as is. | |
7a9ab499 EM |
31 | * |
32 | * @param $context | |
33 | * @param $text | |
34 | * | |
35 | * @return string | |
6a488035 | 36 | */ |
00be9182 | 37 | public function pgettext($context, $text) { |
6a488035 TO |
38 | $key = $context . chr(4) . $text; |
39 | $ret = $this->translate($key); | |
40 | ||
41 | if (strpos($ret, "\004") !== FALSE) { | |
42 | return $text; | |
43 | } | |
44 | else { | |
45 | return $ret; | |
46 | } | |
47 | } | |
48 | ||
a0ee3941 EM |
49 | /** |
50 | * @param $text | |
51 | * @param $plural | |
52 | * @param $count | |
53 | * | |
54 | * @return string | |
55 | */ | |
00be9182 | 56 | public function ngettext($text, $plural, $count) { |
6a488035 TO |
57 | return ngettext($text, $plural, $count); |
58 | } | |
96025800 | 59 | |
6a488035 | 60 | } |