本文整理汇总了PHP中dcgettext函数的典型用法代码示例。如果您正苦于以下问题:PHP dcgettext函数的具体用法?PHP dcgettext怎么用?PHP dcgettext使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dcgettext函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pgettext
function pgettext($context, $msgId)
{
$contextString = "{$context}{$msgId}";
$translation = dcgettext(textdomain(NULL), $contextString, LC_MESSAGES);
if ($translation == $contextString) {
return $msgId;
} else {
return $translation;
}
}
示例2: dpgettext
/**
* Context-aware dgettext 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 $domain domain identifier, or null for default domain
* @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 dpgettext($domain, $context, $msg)
{
$msgid = $context . "" . $msg;
$out = dcgettext($domain, $msgid, LC_MESSAGES);
if ($out == $msgid) {
return $msg;
} else {
return $out;
}
}
示例3: dcpgettext
function dcpgettext($domain, $msg_ctxt, $msgid, $category)
{
$msg_ctxt_id = "{$msg_ctxt}{$msgid}";
$translation = dcgettext($domain, $msg_ctxt_id, $category);
if ($translation == $msg_ctxt_id) {
return $msgid;
} else {
return $translation;
}
}
示例4: lang
/**
* Return a translated string.
*
* @param String $identifier Identifier for the requested string
* @param String $context Context information fot the requested string
*
* @return String $string Translated string, identifier by default
*/
public function lang($identifier, $context = '')
{
if (strlen($identifier) + strlen($context) + 1 > self::GETTEXT_MAX_MSGID_LENGTH) {
$this->logger->warning('Identifier too long: ' . $identifier);
return $identifier;
}
$this->init($this->language);
if ($context == '') {
return gettext($identifier);
}
// Glue msgctxt and msgid together, with ASCII character 4
// (EOT, End Of Text)
$composed = "{$context}{$identifier}";
$output = dcgettext($this->domain, $composed, LC_MESSAGES);
if ($output == $composed && $this->language != $this->default_language) {
return $identifier;
} else {
return $output;
}
}
示例5: search
public function search($domain = '', $message = '', $category = 0)
{
if (!is_string($domain) || !is_string($message)) {
return Error::set(lang('Error', 'stringParameter', '1.(domain) & 2.(message)'));
}
return dcgettext($domain, $message, $category);
}
示例6: cquery
/**
* {@inheritdoc}
*
* @param string $msgid
* @param string $msgctxt Optional. If ommitted or NULL, this method behaves as query().
* @param array $placeholders Optional.
* @param string $category Optional. Specify the locale category. Defaults to LC_MESSAGES
* @return string
* @throws \InvalidArgumentException
*/
public function cquery($msgid, $msgctxt = null, $placeholders = null, $category = LC_MESSAGES, $domain = null)
{
if ($domain !== null && !in_array($domain, $this->domains)) {
throw new \InvalidArgumentException($domain . ' is invalid translation domain');
}
if ($msgctxt === null) {
return $this->query($msgid, $placeholders, $domain);
}
if ($domain === null) {
$domain = textdomain(null);
}
$contextString = "{$msgctxt}{$msgid}";
$translation = dcgettext($domain, $contextString, $category);
if ($translation == $contextString) {
$translation = $msgid;
}
if (is_array($placeholders)) {
foreach ($placeholders as $key => $value) {
$translation = str_replace('%' . $key . '%', $value, $translation);
}
}
return $translation;
}
示例7: T_dcgettext
function T_dcgettext($domain, $msgid, $category)
{
if (_check_locale_and_function()) {
return dcgettext($domain, $msgid, $category);
} else {
return _dcgettext($domain, $msgid, $category);
}
}
示例8: pgettext
/**
* Emulated pgettext()
*
* @link http://php.net/manual/de/book.gettext.php#89975
*
* @param $text
* @param $domain
* @param $context
*
* @return string
*/
public static function pgettext($text, $domain, $context)
{
$contextString = "{$context}{$text}";
$translation = dcgettext($domain, $contextString, defined('LC_MESSAGES') ? LC_MESSAGES : LC_ALL);
if ($translation == $contextString) {
return $text;
} else {
return $translation;
}
}
示例9: cget
/**
* Obtiene una traduccion por categoria, cuando se pasan argumentos adicionales se remplaza con sprintf
*
* @param string $sentence
* @param int $category categoria del mensaje (LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES, LC_ALL)
* @return string
* */
public static function cget($sentence, $category)
{
/**
* Obtengo la traduccion
* */
$sentence = dcgettext(textdomain(null), $sentence, $category);
/**
* Si se pasan multiples parametros
* */
if (func_num_args() > 2) {
$sentence = $sentence = self::sprintf($sentence, func_get_args(), 2);
}
return $sentence;
}
示例10: cquery
/**
* {@inheritdoc}
*
* @param string $msgid
* @param string $msgctxt Optional. If ommitted or NULL,
* this method behaves as query().
* @param array $placeholders Optional.
* @param string $category Optional. Specify the locale category.
* Defaults to LC_MESSAGES
*
* @return string
* @throws \InvalidArgumentException
*/
public function cquery($msgid, $msgctxt = null, $placeholders = null, $category = LC_MESSAGES, $domain = null)
{
if ($msgctxt === null) {
return $this->query($msgid, $placeholders, $domain);
}
$this->setDomain($domain);
$contextString = "{$msgctxt}{$msgid}";
$translation = dcgettext($domain, $contextString, $category);
if ($translation == $contextString) {
$translation = $msgid;
}
return self::setPlaceholders($translation, $placeholders);
}
示例11: gettext
function gettext($sContents)
{
$this->_generateLanguage();
$this->_generateFilePath();
if (empty($this->sFilename)) {
return $sContents;
}
return KTUtil::arrayGet($this->aStrings, $sContents, $sContents);
return dcgettext($this->sDomain, $sContents, LC_MESSAGES);
}
示例12: str_repeat
<?php
$overflown = str_repeat('C', 8476509);
$msgid = "msgid";
$domain = "domain";
$category = "cat";
var_dump(bindtextdomain($overflown, 'path'));
var_dump(dngettext($overflown, $msgid, $msgid, 1));
var_dump(dngettext($domain, $overflown, $msgid, 1));
var_dump(dngettext($domain, $msgid, $overflown, 1));
var_dump(gettext($overflown));
var_dump(ngettext($overflown, $msgid, -1));
var_dump(ngettext($msgid, $overflown, -1));
var_dump(dcgettext($overflown, $msgid, -1));
var_dump(dcgettext($domain, $overflown, -1));
var_dump(dcngettext($overflown, $msgid, $msgid, -1, -1));
var_dump(dcngettext($domain, $overflown, $msgid, -1, -1));
var_dump(dcngettext($domain, $msgid, $overflown, -1, -1));
var_dump(dgettext($overflown, $msgid));
var_dump(dgettext($domain, $overflown));
var_dump(textdomain($overflown));
?>
==DONE==
示例13: search
public function search(string $domain, string $message, int $category = 0) : string
{
return dcgettext($domain, $message, $category);
}
示例14: dcpgettext
public function dcpgettext($context, $domain, $message, $category)
{
return dcgettext($domain, $context . "" . $message, constant($category));
}
示例15: cget
/**
* Obtiene una traduccion por categoria, cuando se pasan argumentos adicionales se remplaza con sprintf
*
* @param string $sentence
* @param int $category categoria del mensaje (LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES, LC_ALL)
* @return string
* */
public static function cget($sentence, $category)
{
/**
* Obtengo la traduccion
* */
$sentence = dcgettext(textdomain(null), $sentence, $category);
/**
* Si se pasan multiples parametros
* */
if (func_num_args() > 2) {
$args = func_get_args();
/**
* Se remplaza con vsprintf
* */
unset($args[0], $args[1]);
$sentence = vsprintf($sentence, $args);
}
return $sentence;
}