Language files problem with plugin installer

General questions regarding the use of languages in Joomla! 1.5.

Moderator: General Support Moderators

Locked
User avatar
elfif
Joomla! Intern
Joomla! Intern
Posts: 57
Joined: Fri Dec 23, 2005 1:33 pm
Location: Bordeaux - France
Contact:

Language files problem with plugin installer

Post by elfif » Tue Jun 23, 2009 3:15 pm

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 :)
Keep smiling with the sun and singing with the birds
www.atelier51.com

User avatar
mcsmom
Joomla! Exemplar
Joomla! Exemplar
Posts: 7985
Joined: Thu Aug 18, 2005 8:43 pm
Location: New York
Contact:

Re: Language files problem with plugin installer

Post by mcsmom » Mon Jun 29, 2009 8:28 am

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).
So we must fix our vision not merely on the negative expulsion of war, but upon the positive affirmation of peace. MLK 1964.
http://officialjoomlabook.com Get it at http://www.joomla.org/joomla-press-official-books.html Buy a book, support Joomla!.

empulsea
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Sat Dec 04, 2010 1:08 pm

Re: Language files problem with plugin installer

Post by empulsea » Sat Dec 04, 2010 1:44 pm

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... :)
Cheers :)
Manoj

pikilon
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Wed Jan 09, 2008 8:46 am

Re: Language files problem with plugin installer

Post by pikilon » Thu Jan 05, 2012 2:32 pm

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!

empulsea
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Sat Dec 04, 2010 1:08 pm

Re: Language files problem with plugin installer

Post by empulsea » Fri Jan 06, 2012 9:05 am

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);
Cheers :)
Manoj

pikilon
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Wed Jan 09, 2008 8:46 am

Re: Language files problem with plugin installer

Post by pikilon » Fri Jan 06, 2012 8:26 pm

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

User avatar
tarunbaraiya
Joomla! Intern
Joomla! Intern
Posts: 53
Joined: Sat Dec 03, 2011 12:36 pm
Contact:

Re: Language files problem with plugin installer

Post by tarunbaraiya » Tue Jan 10, 2012 1:50 pm

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

User avatar
WP4J
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 152
Joined: Fri Mar 22, 2013 6:20 am
Contact:

Re: Language files problem with plugin installer

Post by WP4J » Wed May 01, 2013 8:23 am

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
Billy Dale - Lead Developer for WP4J.com
http://WP4J.com - WordPress completely integrated with Joomla!
http://WP4J.com/demo - Demo the best multiuser blogging component for Joomla!


Locked

Return to “Language - Joomla! 1.5”