Plugin Creation - Language files

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

Moderators: infograf768, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
daniele-nyx
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Tue Oct 29, 2013 5:32 pm

Plugin Creation - Language files

Post by daniele-nyx » Tue Oct 29, 2013 5:47 pm

Hi, i'm new and junior developer.

I have developed a system plugin for joomla and have some problems with different languages files.
I show immediately my situation for make easy the support:

in my_plugin.xml

Code: Select all

<description>PLG_LR_ISTRUCTIONS</description>
and

Code: Select all

<languages>
    <language tag="en-GB">./languages/en-GB.plg_system_my_plugin.sys.ini</language>
    <language tag="en-GB">./languages/en-GB.plg_system_my_plugin.ini</language>
  </languages>
in en-GB.plg_system_my_plugin.sys.ini

Code: Select all

PLG_LR_ISTRUCTIONS="Thank you for installing my plugin. You will find the instructions for setting up in the plugin screen."
and in en-GB.plg_system_my_plugin.ini

Code: Select all

PLG_LR_ISTRUCTIONS="This are the instructions...."
Now i have two problems:
- At the first installation of my plugin, joomla doesn't show the thank you message after installation, but only "PLG_LR_ISTRUCTIONS". At the second installation of the same package instead (an update without uninstall first), joomla is able to retrieve the translation and show correctly "Thank you for installing ..."
- When i open the plugin page i see the thank you message and not the instructions

In one question: how can i show correctly two different messages for installation and plugin instructions?
Thank you

User avatar
alikon
Joomla! Champion
Joomla! Champion
Posts: 5941
Joined: Fri Aug 19, 2005 10:46 am
Location: Roma
Contact:

Re: Plugin Creation - Language files

Post by alikon » Wed Oct 30, 2013 6:31 pm

In one question: how can i show correctly two different messages for installation and plugin instructions?
You can use the installscript class

Code: Select all

   <scriptfile>installscript.php</scriptfile>	
and something like this

Code: Select all

class plgSystemyourpluginInstallerScript
{
         function install( $parent ) {
                echo JText::_('PLG_YOURMSG') ;
        }
 }
Nicola Galgano
i know that i don't know
www.alikonweb.it

daniele-nyx
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Tue Oct 29, 2013 5:32 pm

Re: Plugin Creation - Language files

Post by daniele-nyx » Fri May 02, 2014 11:16 am

Well. First of all, thank you for your reply.

The trick is working (echo "hello world" shows effectively "hello world" as installation message), but when i try

Code: Select all

function install($parent) {
    echo JText::_('PLG_LR_ISTRUCTIONS');
  }
the label "PLG_LR_ISTRUCTIONS" appears instead the related message translated :-\

What is wrong now?
Can somebody helps me? :( :'(

daniele-nyx
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Tue Oct 29, 2013 5:32 pm

Re: Plugin Creation - Language files

Post by daniele-nyx » Fri May 02, 2014 12:11 pm

I've done it!
I've changed my configuration as below:

In my_plugin.xml

Code: Select all

<files>
    <filename plugin="my_plugin">my_plugin.php</filename>
    <filename>index.html</filename>
    <folder>img</folder>
    <folder>language</folder>
  </files>
  <languages folder="language">
    <language tag="it-IT">it-IT/it-IT.plg_system_my_plugin.ini</language>
    <language tag="en-GB">en-GB/en-GB.plg_system_my_plugin.ini</language>
  </languages>
notices, appear to be required:
1. "languages" folder becomes "language" folder
2. added language subfolders "it-IT" and "en-GB"
3. added folder="language" attribute to "languages" parent tag

optional:
4. removed "*.sys.ini" files from xml manifest but still existing and used!!

No scriptinstall file used.
Now the message showed after installation is the PLG_LR_ISTRUCTIONS defined in *.sys.ini file and the message showed in plugin configuration screen is PLG_LR_ISTRUCTIONS defined in *.ini file.

I hope that these instructions will be useful to someone :)

daniele-nyx
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Tue Oct 29, 2013 5:32 pm

Re: Plugin Creation - Language files

Post by daniele-nyx » Mon May 05, 2014 9:04 am

Strange (and very annoying :-\ ) behavior. I wonder if anyone knows how to explain it..

When my plugin is already installated:
- if the plugin is not published yet, the description showed into the plugin page is retrieved from plg_system_my_plugin.ini file (so instruction is showed properly)
- else if the plugin is published, the description showed into the plugin page is retrieved from plg_system_my_plugin.sys.ini file (so is showed the thank you message)

:-\ :'( ??? ??? ???

daniele-nyx
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Tue Oct 29, 2013 5:32 pm

Re: Plugin Creation - Language files

Post by daniele-nyx » Wed May 07, 2014 9:32 am

note: strange behavior exists also in the newer Joomla (3.3.0)


Locked

Return to “Language - Joomla! 2.5”