3

Version Joomla 3.4.2

In our current set-up we would like to able to add the language override folder to the current template folder and then we could achieve 3 things:

  1. We would be able to update the translations with the upload of the new template.
  2. We would be able to quickly batch edit the ini file via Template Manager / Customise template.
  3. We could version control the constant updates of translation overrides by keeping the override folder inside the template

I am aware there exist the possibility to manually edit the ini file via Language Manager, but the labels can only be modified one by one resulting in a very long update process when we have sometimes 800 labels coming from the translation agency.

Additionally our current implementation won't allow us to swap files in the server (production server) . We can only upload new templates and modify files within the templates (thanks to the admin template manager interface).

If I add the overrides folder inside the template all I would need to do is override the function __construct inside \libraries\joomla\language\language.php because that's where the path to the overrides is defined.

How could I override that class to change the location of the language overrides? Can you think of a better way of achieving this under the current restrictions?

4
  • 2
    What is wrong with using the language folder inside your template? The override folder inside /language is for end users that want to override translations for all types of extensions.
    – fruppel
    Nov 10, 2015 at 12:58
  • I understand that language/override is the default location where all language override for any kind of extension should go, but I was wondering how to change the path so that thet were editable via Template Manager: Customise Template, as current solution is not ideal due to our restrictions. Joomla only allows the individual editing of every language label one by one.
    – Mg Gm
    Nov 11, 2015 at 9:57
  • I should have said first that I don't think there is an easy way to override the function. Can you be a little bit more specific about your restrictions and what you are trying to achieve? What I understand is that you can't replace files in your templates but you can upload new templates. Do you want to translate strings that belong to your template or more strings like from other extensions? Why don't you use language folder inside your template as in Seth Warburton's answer?
    – fruppel
    Nov 11, 2015 at 10:41
  • I can't swap any of the language/overides/* files or edit them once in production . I can only edit a label and save one by one. Ideally It would be best to be able to access these ini file very much in the way that other files (like css/js files) are accessed via Template Manager (Template Manager -> Templates -> Select Template -> Select File) Additionally by having overrides in template folder , we could update 1000 times easier once we upload the template, and we could also version translations as part of the template
    – Mg Gm
    Nov 11, 2015 at 15:02

3 Answers 3

2

I think you are overcomplicating this. Just create a template language folder. You can put whatever lang strings you like in there, as they don't have to be used only in your template, and have a file for each language. E.g.

/templates/your-template/language/en-GB/en-GB.tpl_your-template.ini
/templates/your-template/language/de-DE/de-DE.tpl_your-template.ini
2
  • 1
    Sorry I cannot take this as a valid answer to my problem. You can only include tag translation that are actually used within the template (index.php or other files that might be included in the template). Language tags included in that ini file will not override module or component tags already existing in the /language/en-GB/ folder. Additionaly in order for it to work you need to update templateDetails.xml to reflect the location of the ini file for that template
    – Mg Gm
    Nov 11, 2015 at 14:52
  • 1
    Even though this is an incomplete answer, @MgGm's response helped me solve a problem I was having.
    – nizz0k
    Jan 26, 2017 at 14:27
1

You have to load the template language files in the component itself, because Joomla renders the component before the template. Therefore you cannot load an component language override in the template (index.php).

You have to do the following things:

Create:

templates/your_template/language/en-GB/en-GB.com_yourcomponent.ini

Then go to

/components/your_component/yourcomponent.php

Insert before

$controller->execute(JRequest::getCmd('task'));

the following commands:

$language = JFactory::getLanguage();
$language->load('com_yourcomponent' , JPATH_SITE.'/templates/your_template', $language->getTag(), true);

This should work, I have tested this with my custom component some minutes ago.

Untested:

You can use the html/com_yourcomponent/viewname/default.php overrides to load your custom language file I guess. Just put the commands at the top of the file (after _JEXEC).

Maybe this will also work without editing the core component.

0

As I don't have enought reputation to comment Dennis Heiden answer, therefore I choose to give an answer myself just to state that I've tested the second solution given by Dennis Heiden and it works perfectly. Thank you.

To be clear, the given solution that I'm refferring is the following:

$language = JFactory::getLanguage();
$language->load('com_eventgallery' , JPATH_SITE . '/templates/your_template', $language->getTag(), true);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.