当前位置: 首页>>代码示例>>PHP>>正文


PHP dcgettext函数代码示例

本文整理汇总了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;
     }
 }
开发者ID:rizzel,项目名称:dns,代码行数:10,代码来源:page.php

示例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;
     }
 }
开发者ID:himmelex,项目名称:NTW,代码行数:23,代码来源:language.php

示例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;
    }
}
开发者ID:azatoth,项目名称:php-pgettext,代码行数:10,代码来源:pgettext.php

示例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;
     }
 }
开发者ID:rubendgr,项目名称:lunr,代码行数:28,代码来源:GettextL10nProvider.php

示例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);
 }
开发者ID:Allopa,项目名称:ZN-Framework-Starter,代码行数:7,代码来源:GT.php

示例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;
 }
开发者ID:hinablue,项目名称:incubator,代码行数:33,代码来源:Gettext.php

示例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);
    }
}
开发者ID:vezla,项目名称:pH7-Social-Dating-CMS,代码行数:8,代码来源:gettext.inc.php

示例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;
     }
 }
开发者ID:thorebahr,项目名称:icingaweb2,代码行数:21,代码来源:Translator.php

示例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;
 }
开发者ID:Jamp,项目名称:sgas,代码行数:21,代码来源:i18n.php

示例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);
 }
开发者ID:nicklos17,项目名称:appserver,代码行数:26,代码来源:Gettext.php

示例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);
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:10,代码来源:i18n.inc.php

示例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==
开发者ID:badlamer,项目名称:hhvm,代码行数:23,代码来源:44938.php

示例13: search

 public function search(string $domain, string $message, int $category = 0) : string
 {
     return dcgettext($domain, $message, $category);
 }
开发者ID:znframework,项目名称:znframework,代码行数:4,代码来源:InternalGT.php

示例14: dcpgettext

 public function dcpgettext($context, $domain, $message, $category)
 {
     return dcgettext($domain, $context . "" . $message, constant($category));
 }
开发者ID:KacerCZ,项目名称:Twig-extensions,代码行数:4,代码来源:Gettext.php

示例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;
 }
开发者ID:ocidfigueroa,项目名称:sice,代码行数:26,代码来源:i18n.php


注:本文中的dcgettext函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。