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