Ready-made extensions and custom development for Joomla!

  • Home
  • Blog
  • Creating language files for your extensions in Joomla 2.5

Creating language files for your extensions in Joomla 2.5

If you have ever written or translated an extension for Joomla, you will be aware about the use of language files that let your extension be available in every language.

Let's see some additional features that let us translate also the backend menu items and the install message.

How it works

For clarity, in the rest of this post we will assume that we're going to create an english language file for a fictional component com_contest, which has both a backend and a frontend part.

Normal translation

The language files for the component itself are called en-GB.com_contest.ini and are placed in:

  • /administrator/language/en-GB (for the backend)
  • /language/en-GB (for the frontend)

These files are loaded whenever our component is active, i.e. we are in index.php?option=com_contest...

We can also choose to place these files into the component folder itself:

  • /administrator/components/com_contest/language/en-GB
  • /components/com_contest/language/en-GB

Backend menu items

Depending on our xml install file, we may have several menu items for our component under the "Components" backend menu item.

To translate these items, we will have to use a file called en-GB.com_contest.sys.ini (notice the additional sys suffix), which can be placed either in:

  • /administrator//language/en-GB
  • /administrator/components/com_contest/language/en-GB

These files are always loaded, so we can see our menu items translated even when we're in a different component page.

So, in our XML install file we may have something like this:

<administration>
 <menu link="option=com_contest">COM_CONTEST_MENU</menu>
 <submenu>
   <menu link="option=com_contest&...">COM_CONTEST_SUBMENU_1</submenu>
   <menu link="option=com_contest&...">COM_CONTEST_SUBMENU_2</submenu>
 </submenu>
 ...

and in our SYS language file we will have:

COM_CONTEST_MENU="GiBi Contest"
COM_CONTEST_SUBMENU_1="Manage Contest Categories"
COM_CONTEST_SUBMENU_2="Manage Contest Submisssions"

Install message

The install message is the description that appears just after our extension has been successfully installed.

We define that in your XML install file.

If we want to translate it, we will have to use the SYS language file but this file must be placed inside your component folder:

  • /administrator/components/com_contest/language/en-GB

So in your XML install file we may have 

<description>COM_COUPONS_XML_DESC</description>

and in our SYS language file we will have

COM_COUPONS_XML_DESC="A Joomla extension to manage an online contest"

Summary

The necessary files are

  1. /language/it-IT/com_contest.ini (lato frontend)
  2. /administrator/language/com_contest.ini (lato backend)
  3. /administrator/language/com_contest.sys.ini (menu amministrativi)
  4. /administrator/components/com_contest/language/it-IT/com_contest.sys.ini (messaggio di installazione)

We may however simplify our work by using a single file for step 3 and 4 and placing it inside the component folder.

Conclusions

We hope that after this short article you will have a clear notion about how language files works and where they should be placed.

Of course there are related topics that may be worth explaining, like how to build an XML install file, but we will keep that for others articles on this blog!