Documentation Menu

1.5 Template Project

The Joomla! Documentation Working Group is running a project to develop detailed reference and tutorial material on Joomla! 1.5 templates.  There is a project page on the documentation wiki where you can see the work in progress and help us by contributing your knowledge.

Who's Online

We have 20 guests online

Help Site License

The Joomla! Help Site content is copyright © 2005 - 2008 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution NonCommercial ShareAlike 2.5. Some parts of this website may be subject to other licenses.
Home arrow Manual arrow 6. Language Support arrow Chapter 6. Language Support

Chapter 6. Language Support PDF Print E-mail

Overview

The core language support is focused on the static text which is used for the different presentation outputs. Most of the text which you see in the frontend presentation of your web site is defined within the language files and can be changed easily by adding new languages within the language manager (see administrator guide). The language support of Joomla is based on the requirement to have a web site in one certain language. With that requirement the feature enables you to control the following elements of the language presentation:

  • Definition of language for static text elements in the frontend

  • Definition of locale settings for output of dates, currencies

  • Definition of ISO character sets for the HTML header meta tags

    The feature to provide a multilingual web site will be supported by Joomla core in a future release (see roadmap). At the moment the support for multilingual web sites is provided by a third party component  Mamblefish.

     

    Installation and global configuration of languages

    The language file support is based on the language files stored in the /language directory. The management of these files can be done thru the language manager within the administration or by copying the content of the language packages (language file and XML declaration for the language) into the /language directory.

    Each Joomla web site must have one active language (default). To change this language, you have to install a second language and either publish this language within the language manager or activate it in the global configuration. Both actions require administrator rights within your administration and a writeable configuration.php file.

    For further details of installing a language please see the administrator documentation.

    Creation of language files

    To create your own language file it is necessary that you use the exact contents of the default language file and translate the contents of the define statements.

    Files within a language package

    The following files are used within a language package. These files must be provided for each language in order to install reliably within the language manager.
    Table 6-1. Files within the language package

    language_name.php
    Basic file core manager.
    language_name.ignore.php
    Definitions of search words that will be ignored for this language.
    language_name.xml
    Language configuration file. This file contains all information about the language handling and which filenames to be used within the package. In order to provide installation support thru the administrator this file must be contained in the language package.

    Manipulating the static text

    The following code is an extract from the english.php language file. In order to present the static text of your site in a different language, you have to translate the English text. Everything else in the file (especially the define names) must stay the same.

    <?php
    /**
    * @version $Id: languages.xml,v1.5 2004/09/14 22:33:07 eddieajau Exp $
    * @package Joomla
    * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
    * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
    * Joomla! is free software and parts of it may contain or be derived from the
    * GNU General Public License or other free or open source software licenses.
    * See COPYRIGHT.php for copyright notices and details.
    */
     
    /** ensure this file is being included by a parent file */
    defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
     
    /** common */
    DEFINE("_NOT_AUTH","You are not authorized to view this resource.");
    DEFINE("_DO_LOGIN","You need to login.");
    DEFINE('_VALID_AZ09',"Please enter a valid %s.  No spaces, more than %d characters
    and contain 0-9,a-z,A-Z");
    DEFINE('_CMN_YES',"Yes");
    DEFINE('_CMN_NO',"No");
    DEFINE('_CMN_SHOW',"Show");
    DEFINE('_CMN_HIDE',"Hide");

  • The translated version (here into German) would look like:

    <?php
    // $Id: languages.xml,v 1.5 2004/09/14 22:33:07 eddieajau Exp $
    /**
    * Content code
    * @version $Revision: 1.5 $
    * @package Joomla
    * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
    * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
    * Joomla! is free software and parts of it may contain or be derived from the
    * GNU General Public License or other free or open source software licenses.
    * See COPYRIGHT.php for copyright notices and details.
    */
     
    defined( '_VALID_MOS' ) or die( 'Direkter Zugriff zu diesem Bereich ist nicht erlaubt.' );
     
    // common
    DEFINE("_NOT_AUTH","Du bist nicht berechtigt, diesen Bereich zu sehen.");
    DEFINE("_DO_LOGIN","Du musst dich anmelden.");
    DEFINE('_VALID_AZ09',"%s ist nicht zul&auml;ssig.  Bitte keine Leerzeichen, 
         mindestens %d Stellen, 0-9,a-z,A-Z sollte enthalten sein.");
    DEFINE('_CMN_YES',"Ja");
    DEFINE('_CMN_NO',"Nein");
     
    DEFINE('_CMN_NAME',"Name");
    DEFINE('_CMN_DESCRIPTION',"Beschreibung");
    DEFINE('_CMN_SAVE',"Speichern");
  • Language configuration XML

    The configuration XML file is needed for the installation and basic language settings. In the future this XML file will get more importance because it will contain language related information such as the usual charsets and ISO code references for the language. So please be sure to provide this XML file in any language package you distribute.

    <xml version="1.0" encoding="iso-8859-1">
    <mosinstall type="language">
      <name>English</name>
      <version>1.14</version>
      <creationDate>07/07/2004</creationDate>
      <author>Joomla Project</author>
      <authorEmail>admin@joomla.org</authorEmail>
      <files>
        <filename>english.php</filename>
        <filename>english.xml</filename>
      </files>
    </mosinstall>
     

    This XML file covers the standard installer tags and attributes.

    Usage of language files

    When you write your own Joomla component (or, more generally, Joomla element) and have defined your own language file, you only need one line in your program to activate the chosen language:

    include_once('language/'.$mosConfig_lang.'.php');

    This will load the defined text as PHP constants which you have used all over your program.

Last Updated ( Thursday, 09 March 2006 )