我正在编写一个自定义自定义组件,我正在尝试获取组件列表这是我的模型函数
function getComponents()
{
// Initialise variable
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// Get components with permissions
$query->select('name AS value, title AS text, level AS level, rules AS rules')
->from('#__assets')
->where('level > 0')
->where('rules !='.$db->Quote('{}'))
->order('value');
$options = $db->setQuery($query)->loadObjectList();
$levels=array();
if (count($options)) {
foreach ($options as &$option) {
// Translate component name
$option->rules = array_keys(get_object_vars( json_decode($option->rules) ));
$option->text = JText::_($option->text);
$levels[$option->level][] = $option;
}
// Sort by component name
$lang = JFactory::getLanguage();
JArrayHelper::sortObjects($options, 'text', 1, true, $lang->getLocale());
}
return $levels;
}
我的问题是JText::_($option->text);
只翻译我的组件名称,而其他组件保持不变。我的方法有什么问题?