Page 1 of 1

Language files problem with plugin installer

Posted: Tue Jun 23, 2009 3:15 pm
by elfif
Hello,

I don't know where to post this topic, here or in the plugin section ?

I've seen other posts on this subject but it seems that there is no good answer yet.
So I make another try in order to have a good answer or even a new feature in a future release ?

When we create a plugin for several languages that display text in the frontend, there are some annoying limits in Joomla.

Gardener explains the problem very well in this post : http://forum.joomla.org/viewtopic.php?f ... &view=next
Gardener wrote:Extra languages for plugins are installed in the Administrator language area. Since this is hardcoded in the Plugin Installer (setting application to 1 for media and languages) it can't be changed either. I'm wondering what the reasoning for this is, since the plugins are generally used on the frontend.

It's also not how it should work according to the wiki page on creating plugins:
http://docs.joomla.org/How_to_create_a_content_plugin

To make the language load, the loadLanguage() method has to be called with 'administrator' as the second argument.

This wouldn't be much of a problem, except it seems to be fairly common for site administrators to only install the frontend language and keep the administrator in English. I know I do.

The installer also doesn't throw an error if it isn't able to install the language files. Which is odd, as the uninstaller does, if it isn't able to remove the file (which wasn't installed in the first place).
Like Gardener I work with backoffice in English only, but my frontend can have several languages. Language folder for frontend with several subfolder of ini files exist, but language folder for backoffice contains only the en-GB folder...

Even if the workaround of Schlu is technically ok :

Code: Select all

//Load the Plugin language file out of the administration
$lang = & JFactory::getLanguage();
$lang->load('plg_conten_myplugin', JPATH_ADMINISTRATOR);
(quoted from this topic : http://forum.joomla.org/index.php/topic ... 41900.html)

Even, so, this workaround is ok, you need to have as many admin languages installed as there are in your frontend, which is not the case, nor even explained anywhere...

So please, is there a way to create international plugin displaying localized text in frontend ?

Thanks for your answer :)

Re: Language files problem with plugin installer

Posted: Mon Jun 29, 2009 8:28 am
by mcsmom
You may want to post about this in the bugs forum or even better on the cms dev mailing list since they are in alpha for 1.6 (and thus this is a good time for you to propose code to do change).

Re: Language files problem with plugin installer

Posted: Sat Dec 04, 2010 1:44 pm
by empulsea
Thanks elfif ... it worked :) :)

Suppose this is how you have included language file for your plugin in (myplugin.xml) :

<languages folder="language/en-GB">
<language tag="en-GB">en-GB.plg_emailalerts_myplugin.ini</language>
</languages>


You need to add these two lines in your plugin file (myplugin.php):

$lang = & JFactory::getLanguage();
$lang->load('plg_emailalerts_myplugin', JPATH_ADMINISTRATOR);


This will load the language file for your plugin from backend and you can use it for language strings in frontend...

Hope it helps... :)

Re: Language files problem with plugin installer

Posted: Thu Jan 05, 2012 2:32 pm
by pikilon
Thanks for the help but it didn't works for me.

I made a joomla 1.7 plugin with the xml/ini files for config the params.

When I Install them in W7 localhost it works almost perfectly (install msg doesn't show with the language sys or ini file)

In 2 remote (LINUX) sites the language files are not moved to administrator/language/en-GB

if it was a permission problem the language should works if I manually (FTP) upload the 2 files (ini and sys.ini) to this folder, but it doesn't!

There is no error on the installer and I have no clue what's going on,

I am close to start screaming through the window 3 hours with this stupid thing (it take less to make the plugin)

Please help!

Re: Language files problem with plugin installer

Posted: Fri Jan 06, 2012 9:05 am
by empulsea
There is nothing special you need to do in joomla 1.7

You can refer to this joomla plugin located at

"YOUR_JOOMLA/plugins/user/joomla"

joomla.xml

Code: Select all

<languages>
		<language tag="en-GB">en-GB.plg_user_joomla.ini</language>
		<language tag="en-GB">en-GB.plg_user_joomla.sys.ini</language>
</languages>
joomla.php

Code: Select all

// Load user_joomla plugin language (not done automatically).
$lang = JFactory::getLanguage();
$lang->load('plg_user_joomla', JPATH_ADMINISTRATOR);

Re: Language files problem with plugin installer

Posted: Fri Jan 06, 2012 8:26 pm
by pikilon
Thank you for the fast reply but this answer doesn't explain why is working on my local installation.

I think that the problem is that the FTP files (joomla main) set diferent perssion that apache does. I tried in a third server and it works perfectly.

I didn't need to set the lang variable for backend config the plugin works fine with the right permissions, thanks anyway

Re: Language files problem with plugin installer

Posted: Tue Jan 10, 2012 1:50 pm
by tarunbaraiya
i think in joomla 1.6 or 1.7
write this code

Code: Select all

JPlugin::loadLanguage('plg_content_yourplugin');
i hop this will help you

Re: Language files problem with plugin installer

Posted: Wed May 01, 2013 8:23 am
by WP4J
tarunbaraiya wrote:i think in joomla 1.6 or 1.7
write this code

Code: Select all

JPlugin::loadLanguage('plg_content_yourplugin');
i hop this will help you
Thank you man... gosh it can be bothersome to get to the bottom of things like this. Also note that you can store the language file in the plugins dir as opposed to installing to admin or site folders which can be a hassle when exporting your plugin and stuff...

for example I just made a plugin with lang like this:

mysite.com/plugins/community/wp4j/language/en-GB/
en-GB.plg_community_wp4j.ini and en-GB.plg_community_wp4j.sys.ini