简体   繁体   中英

Joomla template language

I have a custom Joomla template, to which I want to apply a template language file. I can put en_GB.tpl_my_tpl.ini into the appropriate place in the language folder of my website and everything works correctly. 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. As far as I understand default Joomla templates use the same technique. I also add to my template xml the following but still no result.

<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).

The $template name is retrieved via $app->getTemplate(true)->template , which originally comes from the template manifest <name>beez_20</name> .

So, as your small XML snippet looks OK, this could be a few things:

  1. The <name> element doesn't have a value of my_tpl in it.
  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
  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

More details, like the key parts of the templateDetails.xml and a directory structure listing would also help us help you.

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:

<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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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