UWAGA: Strona zawiera materiały archiwalne. Większość artykułów dotyczy Joomla! 1.0
6. Język Drukuj Email

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.

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>
  <authore-mail>admin @joomla.org</authore-mail>
  <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.

Zmieniony ( 02.02.2006. )