如何为第 3 方 Joomla 扩展加载语言文件? [英] How does one load a language file for a 3rd party Joomla extension?
问题描述
加载位于管理应用程序中的语言文件的正常方法如下:
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.
这篇关于如何为第 3 方 Joomla 扩展加载语言文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!