X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Flanguage.php;h=a99bf89e3578597529e038a2cb6929c12e6feadb;hb=69ac99ff949ab0118ff25a62471980ad0ec7a52b;hp=bec5620fd1c5ee9397750c0ae84a20f69b7d32c3;hpb=793a4ef4d56b5299a41aa1870d26d8c11cf78271;p=quix0rs-gnu-social.git diff --git a/lib/language.php b/lib/language.php index bec5620fd1..a99bf89e35 100644 --- a/lib/language.php +++ b/lib/language.php @@ -32,6 +32,63 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } +if (!function_exists('gettext')) { + require_once("php-gettext/gettext.inc"); +} + +if (!function_exists('pgettext')) { + /** + * Context-aware gettext wrapper; use when messages in different contexts + * won't be distinguished from the English source but need different translations. + * The context string will appear as msgctxt in the .po files. + * + * Not currently exposed in PHP's gettext module; implemented to be compat + * with gettext.h's macros. + * + * @param string $context context identifier, should be some key like "menu|file" + * @param string $msgid English source text + * @return string original or translated message + */ + function pgettext($context, $msg) + { + $msgid = $context . "\004" . $msg; + $out = dcgettext(textdomain(NULL), $msgid, LC_MESSAGES); + if ($out == $msgid) { + return $msg; + } else { + return $out; + } + } +} + +if (!function_exists('npgettext')) { + /** + * Context-aware ngettext wrapper; use when messages in different contexts + * won't be distinguished from the English source but need different translations. + * The context string will appear as msgctxt in the .po files. + * + * Not currently exposed in PHP's gettext module; implemented to be compat + * with gettext.h's macros. + * + * @param string $context context identifier, should be some key like "menu|file" + * @param string $msg singular English source text + * @param string $plural plural English source text + * @param int $n number of items to control plural selection + * @return string original or translated message + */ + function npgettext($context, $msg, $plural, $n) + { + $msgid = $context . "\004" . $msg; + $out = dcngettext(textdomain(NULL), $msgid, $plural, $n, LC_MESSAGES); + if ($out == $msgid) { + return $msg; + } else { + return $out; + } + } +} + + /** * Content negotiation for language codes * @@ -101,6 +158,7 @@ function get_nice_language_list() */ function get_all_languages() { return array( + 'ar' => array('q' => 0.8, 'lang' => 'ar', 'name' => 'Arabic', 'direction' => 'rtl'), 'bg' => array('q' => 0.8, 'lang' => 'bg', 'name' => 'Bulgarian', 'direction' => 'ltr'), 'ca' => array('q' => 0.5, 'lang' => 'ca', 'name' => 'Catalan', 'direction' => 'ltr'), 'cs' => array('q' => 0.5, 'lang' => 'cs', 'name' => 'Czech', 'direction' => 'ltr'),