note 105340 added to book.gettext

From: Date: Wed, 10 Aug 2011 13:17:56 +0000
Subject: note 105340 added to book.gettext
Groups: php.notes 
Request: Send a blank email to php-notes+get-182392@lists.php.net to get a copy of this message
Based on sasq1 at go2 dot pl's idea, I've made an implementation of all pgettext functions: <?php function pgettext($msg_ctxt, $msgid) { return dpgettext(textdomain(null), $msg_ctxt, $msgid); } function dpgettext($domain, $msg_ctxt, $msgid) { return dcpgettext($domain, $msg_ctxt, $msgid, LC_MESSAGES); } function dcpgettext($domain, $msg_ctxt, $msgid, $category) { $msg_ctxt_id = "{$msg_ctxt}\004{$msgid}"; $translation = dcgettext( $domain, $msg_ctxt_id, $category); if( $translation == $msg_ctxt_id ) { return $msgid; } else { return $translation; } } function npgettext($msg_ctxt, $msgid, $msgid_plural, $n) { return dnpgettext(textdomain(null), $msg_ctxt, $msgid, $msgid_plural, $n); } function dnpgettext($domain, $msg_ctxt, $msgid, $msgid_plural, $n) { return dcnpgettext($domain, $msg_ctxt, $msgid, $msgid_plural, $n, LC_MESSAGES); } function dcnpgettext($domain, $msg_ctxt, $msgid, $msgid_plural, $n, $category) { $msg_ctxt_id = "{$msg_ctxt}\004{$msgid}"; $translation = dcngettext( $domain, $msg_ctxt_id, $msgid_plural, $n, $category); if( $translation == $msg_ctxt_id || $translation == $msgid_plural ) { return $n == 1 ? $msgid : $msgid_plural; } else { return $translation; } } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 87.96.232.93 ---- Manual Page -- http://www.php.net/manual/en/book.gettext.php Edit -- https://master.php.net/note/edit/105340 Del: integrated -- https://master.php.net/note/delete/105340/integrated Del: useless -- https://master.php.net/note/delete/105340/useless Del: bad code -- https://master.php.net/note/delete/105340/bad+code Del: spam -- https://master.php.net/note/delete/105340/spam Del: non-english -- https://master.php.net/note/delete/105340/non-english Del: in docs -- https://master.php.net/note/delete/105340/in+docs Del: other reasons-- https://master.php.net/note/delete/105340 Reject -- https://master.php.net/note/reject/105340 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#182392) next »