Skip to content

Commit

Permalink
Adding $language parameter to I18n::translate()
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Jan 9, 2012
1 parent 08825e5 commit 30522d0
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/Cake/I18n/I18n.php
Expand Up @@ -89,8 +89,7 @@ class I18n {
protected $_noLocale = false;

/**
* Set to true when I18N::_bindTextDomain() is called for the first time.
* If a translation file is found it is set to false again
* Translation categories
*
* @var array
*/
Expand Down Expand Up @@ -129,9 +128,11 @@ public static function &getInstance() {
* @param string $domain Domain The domain of the translation. Domains are often used by plugin translations
* @param string $category Category The integer value of the category to use.
* @param integer $count Count Count is used with $plural to choose the correct plural form.
* @param string $language Language to translate string to.
* If null it checks for language in session followed by Config.language configuration variable.
* @return string translated string.
*/
public static function translate($singular, $plural = null, $domain = null, $category = 6, $count = null) {
public static function translate($singular, $plural = null, $domain = null, $category = 6, $count = null, $language = null) {
$_this = I18n::getInstance();

if (strpos($singular, "\r\n") !== false) {
Expand All @@ -144,10 +145,13 @@ public static function translate($singular, $plural = null, $domain = null, $cat
if (is_numeric($category)) {
$_this->category = $_this->_categories[$category];
}
$language = Configure::read('Config.language');

if (!empty($_SESSION['Config']['language'])) {
$language = $_SESSION['Config']['language'];
if (empty($language)) {
if (!empty($_SESSION['Config']['language'])) {
$language = $_SESSION['Config']['language'];
} else {
$language = Configure::read('Config.language');
}
}

if (($_this->_lang && $_this->_lang !== $language) || !$_this->_lang) {
Expand Down

0 comments on commit 30522d0

Please sign in to comment.