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


PHP dcngettext函数代码示例

本文整理汇总了PHP中dcngettext函数的典型用法代码示例。如果您正苦于以下问题:PHP dcngettext函数的具体用法?PHP dcngettext怎么用?PHP dcngettext使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了dcngettext函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dcnpgettext

function dcnpgettext($domain, $msg_ctxt, $msgid, $msgid_plural, $n, $category)
{
    $msg_ctxt_id = "{$msg_ctxt}{$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;
    }
}
开发者ID:azatoth,项目名称:php-pgettext,代码行数:10,代码来源:pgettext.php

示例2: dnpgettext

 /**
  * Context-aware dngettext 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 $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 dnpgettext($domain, $context, $msg, $plural, $n)
 {
     $msgid = $context . "" . $msg;
     $out = dcngettext($domain, $msgid, $plural, $n, LC_MESSAGES);
     if ($out == $msgid) {
         return $msg;
     } else {
         return $out;
     }
 }
开发者ID:himmelex,项目名称:NTW,代码行数:25,代码来源:language.php

示例3: cnget

 /**
  * Obtiene una traduccion al plural por categoria, cuando se pasan argumentos adicionales se remplaza con sprintf
  *
  * @param string $sentence1 mensaje en singular
  * @param string $sentence2 mensaje en plural
  * @param int $n conteo
  * @param int $category categoria del mensaje (LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES, LC_ALL)
  * @return string
  * */
 public function cnget($sentence1, $sentence2, $n, $category)
 {
     /**
      * Obtengo la traduccion en funcion del dominio
      * */
     $sentence = dcngettext(textdomain(null), $sentence1, $sentence2, $n, $category);
     /**
      * Si se pasan multiples parametros
      * */
     if (func_num_args() > 4) {
         $args = func_get_args();
         /**
          * Se remplaza con vsprintf
          * */
         unset($args[0], $args[1], $args[2], $args[3]);
         $sentence = vsprintf($sentence, $args);
     }
     return $sentence;
 }
开发者ID:ocidfigueroa,项目名称:sice,代码行数:28,代码来源:i18n.php

示例4: searches

 public function searches($domain = '', $msgId1 = '', $msgId2 = '', $count = 0, $category = 0)
 {
     if (!is_string($domain) || !is_string($msgId1) || !is_string($msgId2)) {
         return Error::set(lang('Error', 'stringParameter', '1.(domain) & 2.(msgId1) & 3.(msgId2)'));
     }
     return dcngettext($domain, $msgId1, $msgId2, $count, $category);
 }
开发者ID:Allopa,项目名称:ZN-Framework-Starter,代码行数:7,代码来源:GT.php

示例5: cnquery

 /**
  * {@inheritdoc}
  *
  * @param  string                    $msgid1
  * @param  string                    $msgid2
  * @param  integer                   $count
  * @param  string                    $msgctxt      Optional. If ommitted or NULL, this method behaves as nquery().
  * @param  array                     $placeholders Optional.
  * @param  string                    $category     Optional. Specify the locale category. Defaults to LC_MESSAGES
  * @return string
  * @throws \InvalidArgumentException
  */
 public function cnquery($msgid1, $msgid2, $count, $msgctxt = null, $placeholders = null, $category = LC_MESSAGES, $domain = null)
 {
     if (!is_int($count) || $count < 0) {
         throw new \InvalidArgumentException("Count must be a nonnegative integer. {$count} given.");
     }
     if ($domain !== null && !in_array($domain, $this->domains)) {
         throw new \InvalidArgumentException($domain . ' is invalid translation domain');
     }
     if ($msgctxt === null) {
         return $this->nquery($msgid1, $msgid2, $count, $placeholders, $domain);
     }
     if ($domain === null) {
         $domain = textdomain(null);
     }
     $contextString1 = "{$msgctxt}{$msgid1}";
     $contextString2 = "{$msgctxt}{$msgid2}";
     $translation = dcngettext($domain, $contextString1, $contextString2, $count, $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,代码行数:39,代码来源:Gettext.php

示例6: T_dcngettext

function T_dcngettext($domain, $singular, $plural, $number, $category)
{
    if (_check_locale_and_function()) {
        return dcngettext($domain, $singular, $plural, $number, $category);
    } else {
        return _dcngettext($domain, $singular, $plural, $number, $category);
    }
}
开发者ID:vezla,项目名称:pH7-Social-Dating-CMS,代码行数:8,代码来源:gettext.inc.php

示例7: dCNPGetText

 /**
  * Override the domain and category for a plural context-based lookup.
  *
  * @param  string $domain
  * @param  string $context
  * @param  string $msgid1
  * @param  string $msgid2
  * @param  int    $n
  * @param  int    $category
  * @return string
  */
 public function dCNPGetText($domain, $context, $msgid1, $msgid2, $n, $category)
 {
     if ($this->driver->hasLocaleAndFunction('dcngettext')) {
         $context_id = "{$context}{$msgid1}";
         $translation = dcngettext($domain, $context_id, $msgid2, $n, $category);
         if ($translation == $context_id || $translation == $msgid2) {
             return $n == 1 ? $msgid1 : $msgid2;
         }
         return $translation;
     }
     return $this->driver->dCNPGetText($domain, $context, $msgid1, $msgid2, $n, $category);
 }
开发者ID:pauluse,项目名称:laravel-gettext,代码行数:23,代码来源:Gettext.php

示例8: pngettext

 /**
  * Emulated pngettext()
  *
  * @link http://php.net/manual/de/book.gettext.php#89975
  *
  * @param $textSingular
  * @param $textPlural
  * @param $number
  * @param $domain
  * @param $context
  *
  * @return string
  */
 public static function pngettext($textSingular, $textPlural, $number, $domain, $context)
 {
     $contextString = "{$context}{$textSingular}";
     $translation = dcngettext($domain, $contextString, $textPlural, $number, defined('LC_MESSAGES') ? LC_MESSAGES : LC_ALL);
     if ($translation == $contextString || $translation == $textPlural) {
         return $number == 1 ? $textSingular : $textPlural;
     } else {
         return $translation;
     }
 }
开发者ID:thorebahr,项目名称:icingaweb2,代码行数:23,代码来源:Translator.php

示例9: cnquery

 /**
  * {@inheritdoc}
  *
  * @param  string $msgid1
  * @param  string $msgid2
  * @param  integer $count
  * @param  string $msgctxt     Optional. If ommitted or NULL, this method behaves as nquery().
  * @param  array $placeholders Optional.
  * @param  string $category    Optional. Specify the locale category. Defaults to LC_MESSAGES
  * @param  string $domain      Optional.
  *
  * @return string
  * @throws \InvalidArgumentException
  */
 public function cnquery($msgid1, $msgid2, $count, $msgctxt = null, $placeholders = null, $category = LC_MESSAGES, $domain = null)
 {
     self::validateCount($count);
     if ($msgctxt === null) {
         return $this->nquery($msgid1, $msgid2, $count, $placeholders, $domain);
     }
     $this->setDomain($domain);
     $context = "{$msgctxt}";
     $translation = dcngettext($domain, $context . $msgid1, $context . $msgid2, $count, $category);
     if (strpos($translation, $context, 0) === 0) {
         $translation = substr($translation, strlen($context));
     }
     return self::setPlaceholders($translation, $placeholders);
 }
开发者ID:nicklos17,项目名称:appserver,代码行数:28,代码来源:Gettext.php

示例10: cnget

 /**
  * Obtiene una traduccion al plural por categoria, cuando se pasan argumentos adicionales se remplaza con sprintf
  *
  * @param string $sentence1 mensaje en singular
  * @param string $sentence2 mensaje en plural
  * @param int $n conteo
  * @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 cnget($sentence1, $sentence2, $n, $category)
 {
     /**
      * Obtengo la traduccion en funcion del dominio
      * */
     $sentence = dcngettext(textdomain(null), $sentence1, $sentence2, $n, $category);
     /**
      * Si se pasan multiples parametros
      * */
     if (func_num_args() > 4) {
         $sentence = self::sprintf($sentence, func_get_args(), 4);
     }
     return $sentence;
 }
开发者ID:Jamp,项目名称:sgas,代码行数:23,代码来源:i18n.php

示例11: 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

示例12: searches

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

示例13: dcnpgettext

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

示例14: nlang

 /**
  * Return a translated string, with proper singular/plural form.
  *
  * @param String  $singular Identifier for the singular version of
  *                          the string
  * @param String  $plural   Identifier for the plural version of
  *                          the string
  * @param Integer $amount   The amount the translation should be based on
  * @param String  $context  Context information fot the requested string
  *
  * @return String $string Translated string, identifier by default
  */
 public function nlang($singular, $plural, $amount, $context = '')
 {
     if (strlen($singular) + strlen($context) + 1 > self::GETTEXT_MAX_MSGID_LENGTH) {
         $this->logger->warning('Identifier too long: ' . $singular);
         return $singular;
     }
     $this->init($this->language);
     if ($context == '') {
         return ngettext($singular, $plural, $amount);
     }
     // Glue msgctxt and msgid together, with ASCII character 4
     // (EOT, End Of Text)
     $composed = "{$context}{$singular}";
     $output = dcngettext($this->domain, $composed, $plural, $amount, LC_MESSAGES);
     if (($output == $composed || $output == $plural) && $this->language != $this->default_language) {
         return $amount == 1 ? $singular : $plural;
     } else {
         return $output;
     }
 }
开发者ID:rubendgr,项目名称:lunr,代码行数:32,代码来源:GettextL10nProvider.php

示例15: var_dump

<?php

var_dump(dcngettext(1, 1, 1, 1));
var_dump(dcngettext(1, 1, 1, 1, 1));
var_dump(dcngettext("test", "test", "test", 1, 1));
var_dump(dcngettext("test", "test", "test", 0, 0));
var_dump(dcngettext("test", "test", "test", -1, -1));
var_dump(dcngettext("", "", "", 1, 1));
var_dump(dcngettext("", "", "", 0, 0));
echo "Done\n";
开发者ID:badlamer,项目名称:hhvm,代码行数:10,代码来源:dcngettext.php


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