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


PHP TranslatorInterface::get方法代码示例

本文整理汇总了PHP中Symfony\Component\Translation\TranslatorInterface::get方法的典型用法代码示例。如果您正苦于以下问题:PHP TranslatorInterface::get方法的具体用法?PHP TranslatorInterface::get怎么用?PHP TranslatorInterface::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Translation\TranslatorInterface的用法示例。


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

示例1: translate

 /**
  * @param string $key
  * @param mixed  $default
  *
  * @return mixed
  */
 protected function translate($key, $default = false)
 {
     $string = $this->translator->get($key);
     if ($default !== false) {
         if ($string == $key) {
             return $default;
         }
     }
     return $string;
 }
开发者ID:jumilla,项目名称:laravel-extension,代码行数:16,代码来源:Translator.php

示例2: getAttribute

 /**
  * Get the displayable name of the attribute.
  *
  * @param  string  $attribute
  * @return string
  */
 protected function getAttribute($attribute)
 {
     $primaryAttribute = $this->getPrimaryAttribute($attribute);
     $expectedAttributes = $attribute != $primaryAttribute ? [$attribute, $primaryAttribute] : [$attribute];
     foreach ($expectedAttributes as $expectedAttributeName) {
         // The developer may dynamically specify the array of custom attributes
         // on this Validator instance. If the attribute exists in this array
         // it takes precedence over all other ways we can pull attributes.
         if (isset($this->customAttributes[$expectedAttributeName])) {
             return $this->customAttributes[$expectedAttributeName];
         }
         $line = Arr::get($this->translator->get('validation.attributes'), $expectedAttributeName);
         // We allow for the developer to specify language lines for each of the
         // attributes allowing for more displayable counterparts of each of
         // the attributes. This provides the ability for simple formats.
         if ($line) {
             return $line;
         }
     }
     // When no language line has been specified for the attribute and it is
     // also an implicit attribute we will display the raw attribute name
     // and not modify it with any replacements before we display this.
     if (isset($this->implicitAttributes[$primaryAttribute])) {
         return $attribute;
     }
     return str_replace('_', ' ', Str::snake($attribute));
 }
开发者ID:nsandlin,项目名称:linepig,代码行数:33,代码来源:Validator.php

示例3: getLanguageFileKey

 /**
  * Return the value of input key in the set locale input file (without extension).
  *
  * @param  string  $fileName
  * @param  string  $key
  * @throws InvalidFileNameException
  *
  * @return string
  */
 public function getLanguageFileKey($fileName, $key)
 {
     // Check the input file name
     if (!$this->checkFileName($fileName)) {
         throw new InvalidFileNameException("Input file name is not valid.");
     }
     return $this->translator->get("{$fileName}.{$key}");
 }
开发者ID:arooth,项目名称:multi-language,代码行数:17,代码来源:LanguageManager.php


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