本文整理汇总了PHP中XLite\Core\Translation::getLanguageQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP Translation::getLanguageQuery方法的具体用法?PHP Translation::getLanguageQuery怎么用?PHP Translation::getLanguageQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XLite\Core\Translation
的用法示例。
在下文中一共展示了Translation::getLanguageQuery方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLabelTranslation
/**
* Get label translation
*
* @param string $code Language code OPTIONAL
*
* @return \XLite\Model\LanguageLabelTranslation
*/
public function getLabelTranslation($code = null)
{
$result = null;
$query = \XLite\Core\Translation::getLanguageQuery($code);
foreach ($query as $code) {
$result = $this->getTranslation($code, true);
if (isset($result) || 'en' == $code) {
break;
}
}
return $result;
}
示例2: getSoftTranslation
/**
* Get translation in safe mode
*
* @param string $code Language code OPTIONAL
*
* @return \XLite\Model\Base\Translation
*/
public function getSoftTranslation($code = null)
{
$result = null;
// Select by languages query (current languge -> default language -> hardcoded default language)
$query = \XLite\Core\Translation::getLanguageQuery($this->getTranslationCode($code));
foreach ($query as $code) {
$result = $this->getTranslation($code, true);
if (isset($result)) {
break;
}
}
// Get first translation
if (!isset($result)) {
$result = $this->getTranslations()->first() ?: null;
}
// Get empty dump translation with specified code
if (!isset($result)) {
$result = $this->getTranslation(array_shift($query));
}
return $result;
}
示例3: getCategoryName
/**
* Return translated category name
*
* :KLUDGE: it's the hack to prevent execution of superflous queries
*
* @param array $category Category data
*
* @return string
*/
protected function getCategoryName(array $category)
{
$name = null;
$query = \XLite\Core\Translation::getLanguageQuery(\XLite\Core\Session::getInstance()->getLanguage()->getCode());
foreach ($query as $code) {
$data = \Includes\Utils\ArrayManager::searchInArraysArray($category['translations'], 'code', $code);
if (!empty($data)) {
$name = $data['name'];
break;
}
}
return $name;
}