joomla-强制从特定语言中获取关键字 [英] joomla - forcibly get keyword from specific language

查看:127
本文介绍了joomla-强制从特定语言中获取关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要以给我想要翻译的语言的方式使用JText.已经在调用JText函数之前尝试设置/加载该语言,但是尽管成功加载了语言,但它始终会返回默认语言的关键字.该网站默认情况下为西班牙语,但是有一个组件我需要强行获取它的英文关键字.这是我试图做的:

I need to use JText in a way that I give it the language I want to be translated. Already tried to set/load that language before calling the JText function, but despite the result of language loading is successful, it always returns the default language's keywords. The site is in Spanish language by default, but there's a component that I need to forcibly get English keywords for it. This is what I tried to do:

JText::_("HELLO"); // This returns the Spanish word
JFactory::getLanguage()->load('joomla', JPATH_BASE, 'en-GB, true); // Loading English language
echo JFactory::getLanguage()->getTag();  // This returns en-GB tag!
JText::_("HELLO"); // This returns the Spanish word, too!!!

我希望JText类具有以下内容:

I wish JText class had something like this:

JText::_("HELLO", 'en-GB'); // Return English keyword of the specified key

推荐答案

没关系,我已经通过为URL提供语言"参数来设法加载英语:

Never mind, I've managed to load English language by giving "language" parameter to the URL:

http://example.com/index.php?option=com_test&view=test&language=en-GB

这篇关于joomla-强制从特定语言中获取关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆