简体   繁体   English

Joomla模板语言

[英]Joomla template language

I have a custom Joomla template, to which I want to apply a template language file. 我有一个自定义的Joomla模板,我想向其应用模板语言文件。 I can put en_GB.tpl_my_tpl.ini into the appropriate place in the language folder of my website and everything works correctly. 我可以将en_GB.tpl_my_tpl.ini放入网站语言文件夹中的适当位置,然后一切正常。 But I would like to put this files to my template folder so that to have easier access to my language files. 但是我想将此文件放到我的模板文件夹中,以便更轻松地访问我的语言文件。

I read what people write about this and it seems to me that if I put template/my_template/language/en_GB/en_GB.tpl_my_tpl.ini it should work correctly but it does not. 我读了人们对此的评论,在我看来,如果我输入template / my_template / language / en_GB / en_GB.tpl_my_tpl.ini,它应该可以正常工作,但不能正常工作。 As far as I understand default Joomla templates use the same technique. 据我了解,默认的Joomla模板使用相同的技术。 I also add to my template xml the following but still no result. 我还将以下内容添加到模板xml中,但仍然没有结果。

<languages folder="language">
        <language tag=”en_GB”>en_GB.tpl_my_tpl.ini</language>
</languages>

Am I doing something wrong and how to overcome the matter? 我是在做错什么,如何解决这个问题?

When JLanguage::load() is called the first parameter is the $extension , which in the case of templates is the template name eg tpl_beez_20 (where tpl_ is prepended to the template name during the ComponentHelper renderComponent() call in the JSite 's dispatch() method). JLanguage::load()被调用的第一个参数是$extension ,这在模板的情况下是模板名称,如tpl_beez_20 (其中tpl_前置到模板name的ComponentHelper期间renderComponent()的调用JSitedispatch()方法)。

The $template name is retrieved via $app->getTemplate(true)->template , which originally comes from the template manifest <name>beez_20</name> . $template名称是通过$app->getTemplate(true)->template检索的,它最初来自模板清单<name>beez_20</name>

So, as your small XML snippet looks OK, this could be a few things: 因此,当您的XML小片段看起来不错时,这可能是几件事情:

  1. The <name> element doesn't have a value of my_tpl in it. <name>元素中没有my_tpl的值。
  2. Your not actually re-installing the template just modifying the XML and for some reason Joomla isn't updating it's cached copy of the manifest — try using the Discover feature of the Extension Manger 您实际上并没有在修改XML的情况下重新安装模板,并且由于某些原因Joomla并未更新清单的缓存副本,请尝试使用Extension Manger器的Discover功能
  3. Your template folder is not named correctly, in your question you have /template/my_template you may just have typed this incorrectly, but, if your templateDetails.xml is specifying my_tpl as the <name> your path should be /templates/my_tpl/... (While its been a few years since I've made a template the rule used to be that "the name tag must include the exact name of the folder that the template is to be installed under /templates/ " See TheArtOfJoomla 您的模板文件夹命名不正确,在您的问题中,您输入的是/template/my_template ,可能只是输入了错误的名称,但是,如果您的templateDetails.xmlmy_tpl指定为<name>路径应为/templates/my_tpl/... (尽管自从我制作模板已有好几年了,规则一直是“ name标签必须包含要在/templates/下安装模板的文件夹的确切名称”,请参见TheArtOfJoomla

More details, like the key parts of the templateDetails.xml and a directory structure listing would also help us help you. 更多细节,例如templateDetails.xml的关键部分和目录结构列表,也将帮助我们为您提供帮助。

We do the same exact thing for our custom templates. 我们为自定义模板做同样的事情。 Everything looks good to include the folder name. 一切都很好,包括了文件夹名称。 Not sure why you were told that's wrong. 不知道为什么你被告知那是错误的。 Everything looks good except you're using "_" instead of "-". 除了使用“ _”而不是“-”之外,其他所有内容看起来都不错。 IE... you have: IE ...您有:

<languages folder="language">
        <language tag="en_GB">en_GB.tpl_my_tpl.ini</language>
</languages>

This should be: 应该是:

<languages folder="language">
        <language tag="en-GB">en-GB.tpl_my_tpl.ini</language>
</languages>

If you ever run into any issue in regards to language translation problems, simply follow this debugging guide described in the official Joomla docs here: http://docs.joomla.org/Making_templates_translatable#Debugging_a_translation 如果您遇到有关语言翻译问题的任何问题,只需按照此处Joomla官方文档中描述的调试指南进行操作: http : //docs.joomla.org/Making_templates_translatable#Debugging_a_translation

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM