Adding a Phocamaps Plugin language file

Phoca plugins - support for all Phoca plugins except Phoca Gallery plugins
willson
Phoca Member
Phoca Member
Posts: 36
Joined: 16 Mar 2009, 12:26

Adding a Phocamaps Plugin language file

Post by willson »

Wanting to change the text on the routing button I went through the exercise of figuring out how to add an es-ES language file.

Apparently plugin language files are not loaded by default in Joomla.

Some or all of the following might not have been necessary:
  • Copied en-GB.plg_content_phocamaps.ini from administrator/languages/en-GB to es-ES and renamed it
  • Modified a couple of the fields' texts
  • Copied that also to /languages/es-ES for the front end
  • Modified plugins/content/phocamaps.xml (in the frontend only so far) to add
    <language tag="es-ES">language/es-ES/es-ES.plg_content_phocamaps.ini</language> inside <languages> and <administration><languages>
  • Modified plugins/content/phocamaps.php to add JPugin::loadLanguage

    Code: Select all

    			$paramsC	 	= new JParameter( $table->params );
    			$tmpl			= array();
    			
    	// add language loading (also changed XML) 
    			JPlugin::loadLanguage( 'plg_content_phocamaps' );
    		
    			if (!JComponentHelper::isEnabled('com_phocamaps', true)) {
    				JText::_('Phoca Maps Plugin requires Phoca Maps Component');
    				return true;
    			}
    
That seemed to do the trick for at least the front end.

It probably would have been enough to load the com_phocamaps component language file instead of making a new one for the plugin and not modify the XML file. But, hey, it's a start.

If there's a better/correct/elegant solution out there I'd love to hear about it.
-----
Using: Restaurant Menu Pro, Gallery, Maps, Guestbook, PDF
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48706
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Adding a Phocamaps Plugin language file

Post by Jan »

Hi, yes there is such problem :(

Did you tried to load the language pack into both destinations (manually)

administrator/languages/your-LANG/
languages/your-LANG/

I didn't try it but maybe plugin takes the language file from other place :idea: :(
If you find Phoca extensions useful, please support the project
willson
Phoca Member
Phoca Member
Posts: 36
Joined: 16 Mar 2009, 12:26

Re: Adding a Phocamaps Plugin language file

Post by willson »

Yes first I manually put the language files in administrator/languages and /languages but doing only that didn't have any effect.
Then I did the JPlugin::loadLanguage change and that is what seemed to make it work.
Probably my modification to the XML files was not necessary but I cannot be certain because I did that at the same time and have not backed out that change yet.

It seems that the JPlugin::loadLanguage is the key here because, I have read somewhere, that language files are not loaded by default for plugins.
-----
Using: Restaurant Menu Pro, Gallery, Maps, Guestbook, PDF
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48706
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Adding a Phocamaps Plugin language file

Post by Jan »

Ok, thank you for the information, maybe we need to wait until this will be fixed in Joomla!, maybe there is some other problem :(
If you find Phoca extensions useful, please support the project
TopCop
Phoca Member
Phoca Member
Posts: 29
Joined: 19 Jun 2009, 16:36

Re: Adding a Phocamaps Plugin language file

Post by TopCop »

Jan,

does this mean we can not change the language for the plugin at the moment?
I'd need a German version for my page ....

TopCop
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48706
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Adding a Phocamaps Plugin language file

Post by Jan »

Hi, just try it, try to upload the language files to:

administrator/language/de-DE/
language/de-DE/
maybe it will work :idea:
If you find Phoca extensions useful, please support the project
TopCop
Phoca Member
Phoca Member
Posts: 29
Joined: 19 Jun 2009, 16:36

Re: Adding a Phocamaps Plugin language file

Post by TopCop »

OK, I'll have a try.
What file do I have to copy exactly?
The en-GB.plg_content_phocamaps.ini?


TopCop
willson
Phoca Member
Phoca Member
Posts: 36
Joined: 16 Mar 2009, 12:26

Re: Adding a Phocamaps Plugin language file

Post by willson »

I retried the whole scenario to find out the minimum changes I had to do to add Spanish language:
  • Copy en-GB.plg_content_phocamaps.ini to the /language/es-ES folder
  • Rename the file to es-ES.plg_content_phocamaps.ini
  • Edit the file to put in the language strings you need
  • Add

    Code: Select all

    // add language loading 
             JPlugin::loadLanguage( 'plg_content_phocamaps' );
    just before
    if (!JComponentHelper::isEnabled('com_phocamaps', true)) {
    of
    /plugins/content/phocamaps.php; someplace around line 55 in the current version of phocamaps (1.0.3).
This procedure is for modifying the plugin only. It does not change the component; which would require a different procedure.
If you reinstall/upgrade the phocamaps plugin you would have to redo the code modification.

That's it.
Short version of the instructions: create the new language file; add a call to the language file to the phocamaps plugin code.

The code modification appears to be needed because of Joomla!'s default handling of languages for plugins.

Note: This change was made on a site that does not use Joom!Fish or any other multiple-language component. It is one language only; Spanish.

Edit: http://forum.joomla.org/viewtopic.php?p ... 2#p1386982 says
You need to manually load the translations for plugins using

$this->loadLanguage( );

in the plugins constructor.
So that might be an even better code modification - which I've not tried yet.
-----
Using: Restaurant Menu Pro, Gallery, Maps, Guestbook, PDF
TopCop
Phoca Member
Phoca Member
Posts: 29
Joined: 19 Jun 2009, 16:36

Re: Adding a Phocamaps Plugin language file

Post by TopCop »

Thank you very much for your instructions.
Anyway, I'm running my page in GErman and English. Therefore I have JoomFish installed.
Tried to do it the way you described, but I still get everything in English.

TopCop
willson
Phoca Member
Phoca Member
Posts: 36
Joined: 16 Mar 2009, 12:26

Re: Adding a Phocamaps Plugin language file

Post by willson »

Ah, I see, a different setup. I'm running one language (Spanish) only.

Just an idea, since my Joom!Fish based site doesn't yet have Phocamaps on it so I can't check/test, is that in JF Control Panel you might need a "Content Element" for the Phocamaps component (see http://www.joomfish.net/en/documentatio ... t-elements ). Phocagallery has one and Phocamaps probably needs one to work with Joom!Fish.
-----
Using: Restaurant Menu Pro, Gallery, Maps, Guestbook, PDF
Post Reply