<?php
/**
* Localize.php
* this file is contains Localize class definition
*
* @copyright Copyright (c) 2009 Igor Hlina
* @license read LICENCE.txt
*
*/
/**
* Localize class
* This is only example of class, which provides localized messages.
* Localized messages is in this example stored in simple array.
* Feel free to implement custom storage engine.
*
*/
class Localize
{
/**
* Associative array with translations
*
* @var array
*/
private $translations = array(
'Error404' => 'Stránka sa nenašla',
'ErrorDatabase' => 'Databázová chyba',
'TitleIndex' => 'Vitajte',
'TitleNews' => 'Novinky',
'TitleTable' => 'Príklad tabulky',
),
'Error404' => 'Page not found',
'ErrorDatabase' => 'Database Error',
'TitleIndex' => 'Welcome',
'TitleNews' => 'News',
'TitleTable' => 'Table example',
)
);
/**
* Constructor
*
*/
public function __construct()
{
}
/**
* Return localized message identified by given name
*
* @param string $name
* @param string $lang
* @return string
*/
public function getLocalizedMessage($name, $lang)
{
return $this->translations[$lang][$name];
} else {
throw new Exception("Localized message '$name' not found!");
}
} else {
throw new Exception("Translations for language '$lang' not found!");
}
}
}