Question

I am in the process of creating a Joomla 2.5 Component which should be installed together with an associated Plugin. Therefore i'm using the concept of "Package" as described here: http://docs.joomla.org/Package

My Questions is: how do i implement a translatable text which is displayed post installation?

If you look at my package-xml-file i'd like to have the placeholder MY_PACKAGE_DESCRIPTION translated.

<?xml version="1.0" encoding="utf-8"?>
<extension version="2.5" type="package">
    <name>My Package</name>
    <author></author>
    <creationDate>January 2014</creationDate>
    <packagename>mycomponent</packagename>
    <copyright>©2014</copyright>
    <url></url>
    <version>1.0.0</version>
    <packager></packager>
    <packagerurl></packagerurl>
    <description>MY_PACKAGE_DESCRIPTION</description>
    <update></update>
    <scriptfile>installer.php</scriptfile>
    <files folder="packages">
        <file type="component" id="com_mycomponent" >com_mycomponent.zip</file>
        <file type="plugin" id="myplugin" group="quickicon">plg_quickicon_myplugin.zip</file>
    </files>
    <languages folder="language">
        <language tag="en-GB">en-GB.pkg_mypackage.sys.ini</language>
        <language tag="de-DE">de-DE.pkg_mypackage.sys.ini</language>
    </languages>
</extension>

I tried to create dedicated language files for the package but neither those nor the language files of my component or plugin are referenced during installation.

Solution

I finally got everything working as expected. You have to be very careful with the naming of the XML-Elements and the naming and location of your files.

Like cppl pointed out the packagename needs to be reflected in the name of the language files. Also Joomla seems to require the language files in the exact location (relative to the root-path in your zipfile):

language/[language tag]/[language file]

So finally this did work:

<packagename>mypackage</packagename>
...
<languages folder="language">
    <language tag="en-GB">en-GB/en-GB.pkg_mypackage.sys.ini</language>
    <language tag="de-DE">de-DE/de-DE.pkg_mypackage.sys.ini</language>
</languages>

I also was struggling in getting the installer script to run during the package installation.

<scriptfile>installer.php</scriptfile>

Following the Joomla naming conventions the correct naming of the installer class has to be

class pkg_mypackageInstallerScript {
    ...
}

Finally the corresponding folder-structure in the installable ZIP-Package is now as follows:

pgk_mypackage.xml
installer.php
packages/com_mycomponent.zip
packages/plg_quickicon_myplugin.zip
language/de-DE/de-DE.pkg_mypackage.sys.ini
language/en-GB/en-GB.pkg_mypackage.sys.ini
Was it helpful?

Solution

The main problem I see is the packagename element doesn't match the language element. You have (in your question at least)

<packagename>mycomponent</packagename>
...
<languages folder="language">
    <language tag="en-GB">en-GB.pkg_mypackage.sys.ini</language>
    <language tag="de-DE">de-DE.pkg_mypackage.sys.ini</language>
</languages>

To work with these language files your <packagename> should be:

<packagename>mypackage</packagename>

You can see this if you look at the package adapter in Joomla 2.5:

public function loadLanguage($path)
{
    $this->manifest = $this->parent->getManifest();
    $extension = 'pkg_' . strtolower(JFilterInput::getInstance()->clean((string) $this->manifest->packagename, 'cmd'));
    $lang = JFactory::getLanguage();
    $source = $path;
    $lang->load($extension . '.sys', $source, null, false, false)
        || $lang->load($extension . '.sys', JPATH_SITE, null, false, false)
        || $lang->load($extension . '.sys', $source, $lang->getDefault(), false, false)
        || $lang->load($extension . '.sys', JPATH_SITE, $lang->getDefault(), false, false);
}

In, psuedo, it literally assembles 'pkg_' . <packagename> . '.sys' as the file name.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top