Joomla 2.5 Package installation with language strings - joomla

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

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.

Related

language file in joomla is not working properly?

http://127.0.0.1/COM/administrator/index.php?option=com_process_name
when i click on my newly created component form components menu "com_process_name" should be translated from language.ini file but joomla 3.1 is not translating that file properly as shown above.
my com.process.sys_language.ini file
COM_PROCESS_NAME="Hello World"
but when I watch it from extension Manager->manage it shows its proper name Hello World
I am using JOOMLA 3.1.5
my manifest file
<extension type="component" version="3.1" method="upgrade">
<name>COM_PROCESS_NAME</name>
<author>Arslan Tahir</author>
<creationDate>25 DEC 2013</creationDate>
<copyright>GPL</copyright>
thats how i am including language file
<languages folder="components/com_process">
<language tag="en-GB">en-GB/en-GB.com_process.ini</language>
<language tag="en-GB">en-GB/en-GB.com_process.sys.ini</language>
</languages>
The URl used to view your component such as:
index.php?option=com_process_name
is generated by the component name com_process_name which cannot be translated. Anywhere else on Joomla, it can be

Joomla error uploading hand-coded template

I'm trying to upload my hand-coded template to Joomla 2.5.
I have moved it to the templates folder online. Now I'm trying to INSTALL it from Extension Manager > Install (I see the path to it in the textbox against the Install button). But upon clicking the button, I get this error:
-1 - An error has occurred.
Copy failed
Here's my XML file:
<?xml version="1.0" encoding="utf-8"?>
<extension version="2.5" type="template">
<name>Travels</name>
<description>
Template for Target Travels
</description>
<files>
<filename>index.php</filename>
<filename>catergory.php</filename>
<filename>templateDetails.xml</filename>
<filename>css/template.css</filename>
<filename>css/mystyle.css</filename>
<filename>css/common.css</filename>
<filename>css/crasel.css</filename>
<filename>css/jquery.jcarousel.css</filename>
<filename>css/skin.css</filename>
<folder>css</folder>
<folder>images</folder>
</files>
<positions>
<position>breadcrumb</position>
<position>welcome</position>
<position>tour_catergory</position>
<position>left</position>
<position>right</position>
<position>top</position>
<position>user1</position>
<position>user4</position>
<position>footer</position>
</positions>
</extension>
Any idea on the cause and how to fix it?
This is usually due to permission issues with folders. In the Joomla backend go to:
Site (top menu) >> System Information >> Directory Permissions and ensure the "templates" folder is writable. Whilst you're at it, ensure all folder and files in the list are writable.
Hope this helps
If your template is already in place you should use discover install not install from directory. You have no need to copy files if the files are already where they need to be.

Load language file during joomla (2.5) system plugin installation

I'm having a real hard time showing a localized string during the installation of a system plugin (in Joomla 2.5). The "normal" way with localized strings in the xml file doesn't seem to work, (see this other question: Language based installation description).
I now tried the way proposed there, to show the description via the install scripts. This kind of works (I can echo text successfully), however, I also can't localize there - when debugging the language it shows that the plugin.sys.ini is not loaded yet; I tried to manually load the file, but had no success with loading any of my plugin language files.
This is what I got so far (in a file named setupscripts.php):
<?php // no direct access
defined('_JEXEC') or die('Restricted access');
class plgsystemmyplgnameInstallerScript {
static function loadLanguage() {
$lang =& JFactory::getLanguage();
$lang->load('plg_system_myname', JPATH_ADMINISTRATOR);
}
function install($parent)
{
self::loadLanguage();
echo JTEXT::_("PLG_MYNAME_TEST_TEXT");
}
function uninstall($parent)
{
self::loadLanguage();
echo JText::_('PLG_MYNAME_UNINSTALL_TEXT');
}
function update($parent)
{
self::loadLanguage();
echo JText::_('PLG_MYNAME_UPDATE_TEXT');
}
function preflight($type, $parent) {}
function postflight($type, $parent) {
self::loadLanguage();
echo JText::_('PLG_MYNAME_INSTALL_TEXT');
}
}
But I only get ??PLG_MYNAME_TEST_TEXT?? ??PLG_MYNAME_INSTALL_TEXT?? (language debugging is turned on) during installation... weirdly enough, the language debug feature at the bottom of the page under "untranslated strings" shows "None" (where do the question marks then come from if not from a tried but failed translation???).
Tried some variations of it (with .sys at the end of the plugin name, since I actually think the setup strings should be in the .sys.ini file, without the second parameter (leaving it default), but no luck - no error, nothing in the log (in fact my log file isn't existing, probably there was no entry yet? can one set the log level with Joomla?). But never is there any file loaded (nothing changes under "loaded language files".
Anybody got an idea how to load the language properly?
Is there something special to consider when loading languages during setup? Why is there no error message if loading the languages fails? Do I maybe have to install the language files to a special location to get them recognized during installation? My current xml looks like this:
<extension version="2.5" type="plugin" group="system" method="upgrade">
<name>PLG_MYNAME</name>
<!-- ... author, copyright, version, .. -->
<scriptfile>setupscripts.php</scriptfile>
<files>
<filename plugin="myname">myname.php</filename>
<filename>setupscripts.php</filename>
<filename>index.html</filename>
<folder>sql</folder>
</files>
<!-- ... install->sql->file ... -->
<!-- ... uninstall->sql->file ... -->
<!-- ... update->schemas->schemapath ... -->
<languages [folder="admin"]>
<language tag="en-GB">en-GB.plg_system_myname.ini</language>
<language tag="en-GB">en-GB.plg_system_myname.sys.ini</language>
<!-- ... other languages ... -->
</languages>
<!-- ... config->fields->fieldset->field ... -->
</extension>
(the square brackes around folder="admin" are supposed to indicate that I tried both with and without this attribute. It doesn't change anything).
It only works on installation if you also copy the files to the admin language folder. If you look at the core extensions you will see that they do both. It's really a bug but that's the work around.
Finally I found out how to really do it. A thorough search in the google Joomla dev group brought up this very similar question.
Basically, the language files need to reside in a separate language folder it seems, and the files section also needs to reference them. My xml now looks like this:
<!-- ... everything else stayed the same, except: -->
<files>
<filename plugin="myplg">myplg.php</filename>
<filename>index.html</filename>
<folder>language</folder>
<folder>sql</folder>
</files>
<languages folder="language">
<language tag="en-GB">en-GB/en-GB.plg_system_myplg.ini</language>
<language tag="en-GB">en-GB/en-GB.plg_system_myplg.sys.ini</language>
<!-- .. other languages ... ->
</languages>
<!-- ... rest of the xml file ... -->
The language files are now all in separate subfolders... they get copied to the exact same location as before (administrator/language//...), but now the description from the XML is also localized!
I find it very weird that there are so many ways to specify language files, which all basically work except for the one corner case of the installation...
Hope this will help other people struggling with this!

Joomla! 2.5 language file - translate description

I create a new plugin for joomla 2.5, and in xml i use:
<description>PLG_VAR_DESC</description>
But when install, he dont show the the translation but the var on file.
<languages folder="">
<language tag="en-GB">en-GB.plg_system_name.ini</language>
<language tag="en-GB">en-GB.plg_system_name.sys.ini</language>
</languages>
<files>
<folder>images</folder>
<filename>index.html</filename>
<filename>parameters.xml</filename>
<filename plugin="plg_name">plg_name.php</filename>
</files>
I try everything but i cant put this work..
Thanks
Under the administrator panel in Joomla! you can find under Site - Global configuration - System:
This will allow you to see the Joomla! Debug console:
There you can see if the language file your are using is loaded. If it's not loaded, than your manifest file is not consistent.
I think that the problem could be solved with:
<languages folder="admin">
instead of
<languages folder="">
Also for your reference, the Joomla! documentation on "Specification of language files" may be a good read.
I found the problem.. is the name of language file. Thank's for helping me

Is it possible to pass variable to WIX localization file?

I need to use variable in WIX localization file WIXUI_en-us.wxl.
I tried use it like this:
<String Id="Message_SomeVersionAlreadyInstalled" Overridable="yes">A another version of product $(var.InstallationVersionForGUI) is already installed</String>
But it doesn't work. And when I declared property and used it this way:
<String Id="Message_SomeVersionAlreadyInstalled" Overridable="yes">A another version of product [InstallationVersionForGUI] is already installed</String>
doesn't work either.
Where was I wrong?
Thanks for help and your time.
Localization strings are processed at link time, so you can't use $(var) preprocessor variables. Using a [property] reference is supported, as long as the place where the localization string is used supports run-time formatting (e.g., using the Formatted field type).
Your second method should work just fine. This is the same method used by the default .wxl files.
For example, in your .wxl file you would declare your string:
<String Id="Message_Foo">Foo blah blah [Property1]</String>
And in your .wxs file, you declare the property. If you wish, you can declare the property to match a WiX variable (which it sounds like you're trying to do)
<Property Id="Property1">$(var.Property1)</Property>
I was trying to get localization file to use variables. Came across this post:
There are different layers of variables in WiX (candle's preprocessor
variables, Light's WixVariables/localization variables/binder
variables, and MSI's properties). Each have different syntax and are
evaluated at different times:
Candle's preprocessor variables "$(var.VariableName)" are evaluated
when candle runs, and can be set from candle's commandline and from
"" statements. Buildtime environment
properties as well as custom variables can also be accessed similarly
(changing the "var." prefix with other values).
Light's variables accessible from the command-line are the
WixVariables, and accessing them is via the "!(wix.VariableName)"
syntax. To access your variable from your commandline, you would need
to change your String to: This build was prepared on
!(wix.BuildMachine)
If you instead need to have the BuildMachine value exist as an MSI
property at installation time (which is the "[VariableName]" syntax)
you would need to add the following to one of your wxs files in a
fragment that is already linked in:
Now, the environment variable COMPUTERNAME always has held the name of
my build machines in the past, and you can access that this way:
$(env.COMPUTERNAME). So, you can get rid of the commandline addition
to light.exe and change your wxs file like this:
<WixProperty Id="BuildMachine" Value="$(env.COMPUTERNAME)"/>
Preprocessor variables $(var.VariableName) are are processed at link time, so ideally you would use [PropertyName] which would be defined on the main Product element.
The issue sometimes is that property is not yet defined, for instance using the product name on the localization file seems not posible.
This solution was done aiming to only type the product name once given "Super product" as product name:
In case of running through visual studio extension:
Project properties -> Build -> Define variables -> "MyProductName=Super product" (No quotes)
In case of runing from cmd or some other place:
On Light.exe, add -d"MyProductName=Super product"
Into the localization .wxl file:
<String Id="Description" Overridable="yes">Description of !(wix.MyProductName)
to make it more interesting</String>
I have an aditional config file .wxi I include on other files to have some vars, for instance, here i had hardcoded the value but now it's harcoded on the variable definition and I use the given value:
<?xml version="1.0" encoding="utf-8"?>
<Include>
<!-- Define the product name preprocesor variable -->
<?define ProductName="!(wix.ProductNameDefVar)" ?>
<!-- From this point, can use the preprocesor var -->
<?define ProductName_x64="$(var.ProductName) (64bit)" ?>
<?define ProductName_x32="$(var.ProductName) (32bit)" ?>
<?define CompanyDirName = "My company name" ?>
</Include>
Finally, the place where the localization value where the localization text was not interpolating, is like this:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<!-- Include the config file with the preprocesor var -->
<?include $(sys.CURRENTDIR)\Config.wxi?>
<!-- Main product definition -->
<Product Id="$(var.ProductCode)"
Name="$(var.ProductName)"
Language="!(loc.Language)"
Version="$(var.BuildVersion)"
Manufacturer="!(loc.Company)"
UpgradeCode="$(var.UpgradeCode)">
<!-- Package details -->
<!-- Here, Description was not interpolating -->
<Package InstallerVersion="200"
Compressed="yes"
InstallScope="perMachine"
Platform="$(var.Platform)"
Manufacturer="!(loc.Company)"
Description="!(loc.Description)"
Keywords="!(loc.Keywords)"
Comments="!(loc.Comments)"
Languages="!(loc.Language)"
/>
[...]

Resources