本文整理匯總了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;
}