Joomla Module: How to read ini language strings from XML module file? - joomla

mod_modulo.xml file:
<?xml version="1.0" encoding="utf-8"?>
<install type="module" version="1.5.0">
<name>**EXTNAME**</name>
<description>**EXTDESCR**</description>
<files>
.
.
.
</files>
<languages>
<language tag="en-US">languages/en-US.mod_modulo.ini</language>
<language tag="es-ES">languages/es-ES.mod_modulo.ini</language>
</languages>
</install>
es-ES.mod_modulo.xml:
EXTNAME=Mi modulo
EXTDESCR=Descripcion de mi modulo va aqui
I am using Joomla!1.5 to develop modules because I think that newer versions of Joomla are compatible with older modules. Anyway, the question is: How can I set the values of name and description in mod_module.xml to the strings found in the corresponding language file ?

Joomla 1.5's component installation manifest definition includes a section for administrator interface language files:
...
<administration>
<languages folder="administrator/language/">
<language tag="en-GB">en-GB/en-GB.com_my.ini</language>
<language tag="es-ES">es-ES/es-ES.com_my.ini</language>
</languages>
</administration>
...
However, this specification does not work for modules in that version.
The Document type definition used by J1.5's manifest files is no longer served.
Thant's why I am not sure whether the failure to copy the language files to the admin section's folder is a bug or is done by design. Their removal during the uninstallation process indicated that it is indeed a bug.
Joomla! v1.5 module installation is performed by libraries/joomla/installer/adapters/module/php.
This file is not accessing this node during the installation, but is deleting it during uninstall it deletes it:
$this->parent->removeFiles($root->getElementByPath('administration/languages'), 1);
What can you do?
Legacy packages support in 2.5 and 3.x requires compromises. I would personally advise against it, as it cripples your design.
Therefoe, you can either write a Joomla! 2.5+ module, or you can try to hack your way around this, which would not be pretty. Modules don't event have installation scripts, so you cannot even copy the language files during the module installation process.
The first thing that comes to mind is copying the language files to the administrator folder the first time the controller is invoked.
All this should, hopefully, convince you (and anyone reading this post) to switch to the current Joomla! version.

Try this,
In your xml file
<languages>
<language tag="en-US">languages/en-US.mod_modulo.ini</language>
<language tag="es-ES">languages/es-ES.mod_modulo.ini</language>
</languages>
in your mod_modulo.ini file
EXTNAME="Mi modulo"
EXTDESCR="Descripcion de mi modulo va aqui"
in your default.php file have.
echo "Name :".JText::_('EXTNAME');
echo "Description:".JText::_('EXTDESCR');
Hope its help you..

Related

Joomla module. Unable to install language .ini files properly

I made a very simple joomla 3.2 module, but i can not manage to install my language .ini and sys.ini files.
Part of my .xml file
<files>
<filename>mod_myModuleTitle.xml</filename>
<filename module="mod_myModuleTitle">mod_myModuleTitle.php</filename>
<filename>index.html</filename>
<filename>helper.php</filename>
<folder>lib</folder>
<folder>tmpl</folder>
</files>
<languages folder="language">
<language tag="en-GB">en-GB/en-GB.mod_myModuleTitle.ini></language>
<language tag="en-GB">en-GB/en-GB.mod_myModuleTitle.sys.ini></language>
<language tag="it-IT">it-IT/it-IT.mod_myModuleTitle.ini></language>
<language tag="it-IT">it-IT/it-IT.mod_myModuleTitle.sys.ini></language>
</languages>
the ini files are inside myModuleTitle/language/en-GB folder and myModuleTitle/language/it-IT folder
Trying installing I got:
Warning JInstaller: :Install: File does not exist path/to/my/local/web/server/tmp/mod_myModuleTitle/language/en-GB/en-GB.mod_myModuleTitle.ini
EDIT
SOLVED!!!
adding tag
<folder>language</folder>
and removing
<languages folder="language">
<language tag="en-GB">en-GB/en-GB.mod_myModuleTitle.ini></language>
<language tag="en-GB">en-GB/en-GB.mod_myModuleTitle.sys.ini></language>
<language tag="it-IT">it-IT/it-IT.mod_myModuleTitle.ini></language>
<language tag="it-IT">it-IT/it-IT.mod_myModuleTitle.sys.ini></language>
</languages>
solved my problem, languages .ini files are installed and used correctly.
Glad you worked it out, for others looking at this question, the <language> element was deprecated in Joomla 1.6, the recommended approach since then has been for all language files (normal and system) to be stored with the extension.
You can read more about it in Language section of the Manfest files article on the Joomla Doc's site.

Creating and populating subfolders Joomla manifest XML

I've become fairly confused when I'm trying to create a subfolder and populate it with things in my plugin manifest XML.
If I want to create a subfolder and at the same time add files to it, how would that be done? Read comments in the code draft (all names are of course more distinct than used here).
<?xml version="1.0" encoding="utf-8"?>
<extension type="plugin" version="2.5.0" group="group" method="upgrade">
<name>Handelsbanken Finans Delbetalning</name>
<!-- The following elements are optional and free of formatting conttraints -->
<creationDate>July 2013</creationDate>
<author>Emil Carlsson</author>
<authorUrl>http://valid.url</authorUrl>
<copyright>Copyright (C) 2013</copyright>
<version status="BETA">0.0.1</version>
<!-- The description is optional and defaults to the name -->
<description>Plugin description.</description>
<update> <!-- Runs on update; New in 1.6 -->
<schemas>
<schemapath type="mysql">sql/updates/mysql</schemapath>
</schemas>
</update>
<!-- Site Main File Copy Section -->
<!-- Note the folder attribute: This attribute describes the folder
to copy FROM in the package to install therefore files copied
in this section are copied from /site/ in the package -->
<files folder="site">
<filename>plgName.xml</filename>
<filename>plgName.php</filename>
<folder>helpers</folder>
</files>
</extension>
This gives me nothing really. I can't find the folder I shouldhave been created from what I gathered from the documentation. It also doesn't specifies how I populate these folder :(. I am assuming that it is possible to more or less just package all files I want and then it will create the subfolders where I want/need them. But that it is a question of how to write the manifest file. If anyone have a good tutorial about this I would be very thankful :). I've googled until my fingers are almost at the Point of bleeding :(. I guess I could put all the files in the same folder, but I want to have some sort of structure to visualize for other developers what's part of the core of the plugin and what's not part of the plugin core.
Problem is solved. In my not installation script I linked in the files for what I thought only was used by the configuration XML (a field to configurate the plugin). In this file I had the node "files" as well, in this node I'd not linked in the helpers directory. When this was done all the subdirectories was added as well. So in short - Don't forget to link in the folder in all places where you have a files-node.

JInstaller: :Install: Cannot find Joomla XML setup file

I create one template for joomla 2.5. But when I installed it it show the error:
"Failed loading XML file
D:\wamp\www\demoproject\tmp\install_51a44308e27b9\templateDetails.xml
XML: XML declaration allowed only at the start of the document
JInstaller: :Install: Cannot find Joomla XML setup file"
How can I solve it please?
It means your XML file isn't properly written. The actual error is:
XML declaration allowed only at the start of the document
Check the file and make sure
<?xml version="1.0" encoding="utf-8"?>
is the first line in the file. No line breaks or anything else is allowed before this.
That means you try to install the wrong .zip file. It happens often if you try to install a Joomla 1.5 template to a Joomla 1.6 website or the other way around.
Another common reason is, that you try to install the templates download package (<- the ZIP Archive with all the template stuff inside, like the psd file, the docs AND the installation files) , instead of the included installation file.
<extension version="2.5" type="template" client="site"> Try extension tag instead install.
<!DOCTYPE install PUBLIC "-//Joomla! 1.6//DTD template 1.0//EN" "http://www.joomla.org/xml/dtd/1.6/template-install.dtd"> Include the correct doc type.

Joomla | Module internationalization | New developer

I try to create a very simple module in Joomla. While my whole code is correct, and the module working properly, I cannot make it support the I18n feature.
More specific, my module directory is like that:
mod_mymodname:
languages:
en-GB.mod_mymodname.ini
mod_mymodname.php
mod_mymodname.xml
and then in my mod_mymodname.xml I have that code :
<?xml version="1.1" encoding="utf-8"?>
<extension type="module" version="2.5.0" client="site">
<name>MyModName</name>
... Other Options ...
<files>
<filename module="mod_mymodname">mod_mymodname.php</filename>
<filename>mod_mymodname.xml</filename>
</files>
<languages folder="languages">
<language tag="en-GB">en-GB.mod_mod_mymodname.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field name="modid" size="50" type="text" label="MODID" description="Description here" />
</fieldset>
</fields>
</config>
</extensions>
and my en-GB.mod_mymodname.ini has that content in it
MODID=Module ID
The problem is that in my admin section the field label has the value of "MODID" instead of "Module ID"
Is there anything wrong with that ? Is my first Joomla module, and I am not sure if everything is correct.
Note : The module doesn't require any translation in the front-end. I only need I18n for the administration section.
make sure you mentioned correct text for MODID in language file.
en-GB.mod_mymodname.ini ---> This file was used for declaring the text what we given in that module
Just add the following line in en-GB.mod_mymodname.ini this language file.
MODID="Module ID"
Save and check the module.. Hope this will work....
language file need to be in joomla language folder. If you had installed the module from admin then check the language folder and check if your file exists there.
check in administrator/languages/en-GB/
also you may have to change the way you have mentioned language files in your xml.
Have a look at this link for more detailed description
http://docs.joomla.org/Specification_of_language_files#Language_file_naming_conventions_and_precedence
Make sure you also have en-GB.mod_mymodname.sys.ini for translating text coming from the xml.
I thought of something else too. There does seem to be a known issue where for certain strings from the xml are only translated when the language file is in the main language folder rather than the extension language folder. So I usually put copies both places even though it's considered bad practice to put extension files in the core folder.
first add your module.xml language tag
<languages folder="languages">
<language tag="fr-FR">fr-FR.mod_mod_mymodname.ini</language>
<language tag="fr-FR">fr-FR.mod_mod_mymodname.sys.ini</language>
</languages>
then create two new file in your module language folder
fr-FR.mod_mod_mymodname.ini
fr-FR.mod_mod_mymodname.sys.ini
add the text you want to translate in .ini file like
MOD_MYMODULE_USERNAME="this is my mod"
Then add this constant value to your module default.php file like
JText::_ ('MOD_MYMODULE_USERNAME')

Joomla 1.6 Language files in plugins

Upgrading a plugin from Joomla 1.5 to 1.6
Language files, which worked in Joomla 1.5, don't seem to be working:
Here is how they are defined in the ini:
<languages folder="language">
<language tag="en-GB">en-GB.plg_content_AutoReadMore.sys.ini</language>
</languages>
The language file is located in administrator/language/en-GB
I have upgraded it to Joomla 1.6 format by adding double quotes around arguments etc. (Here is the full text: http://pastebin.com/DdTzKpnf)
Please can someone give me any pointers on where I'm going wrong here.

Resources