问题描述
加载位于管理应用中的语言文件的正常方法如下:
The normal way to load a language file located in the admin app is like so:
$language = JFactory::getLanguage();
$language->load('com_yourcomponentname', JPATH_ADMINISTRATOR);
并从站点应用程序加载语言文件:
And to load a language file from the site app:
$language = JFactory::getLanguage();
$language->load('com_yourcomponentname', JPATH_SITE);
这些方法分别从/administrator/language
和/language
加载语言文件.
These methods load language files from /administrator/language
and /language
respectively.
目前,我需要从一个模块加载语言文件,该模块将其语言文件定位在/modules/mod_foo/language
.我该怎么办?
Presently, I need to load a language file from a module that locates its language files at /modules/mod_foo/language
. How would I do that?
推荐答案
好的,就像将JPATH_SITE替换为模块的完整路径一样简单,就像这样:
OK, it's as simple as replacing JPATH_SITE with the full path to the module like so:
$language = JFactory::getLanguage();
$language->load('mod_foo', JPATH_SITE.'/modules/mod_foo');
这当然假定您要加载的语言文件位于:
This of course assumes that the language file you want to load is located at:
/modules/mod_foo/language/xx-XX/xx-XX.mod_foo.ini
我在发布问题之前已经尝试过此操作,但由于输入错误而无法正常工作.
I had tried this before posting the question, but it didn't work due to a silly typo.
这篇关于如何为第三方Joomla扩展程序加载语言文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!