Skip to content

Commit

Permalink
fixes #6492, removing use of define LC_MESSAGES due to inconsistency …
Browse files Browse the repository at this point in the history
…on different operating systems

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8223 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information
gwoo committed Jul 6, 2009
1 parent bc5de16 commit 508f065
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 24 deletions.
15 changes: 4 additions & 11 deletions cake/basics.php
Expand Up @@ -34,13 +34,6 @@
define('WEEK', 7 * DAY);
define('MONTH', 30 * DAY);
define('YEAR', 365 * DAY);
/**
* Add constant for LC_MESSAGES because it is not defined on windows
*/
if (!defined('LC_MESSAGES')) {
define('LC_MESSAGES', 6);
}

/**
* Patch for PHP < 5.0
*/
Expand Down Expand Up @@ -631,9 +624,9 @@ function __n($singular, $plural, $count, $return = false) {
}

if ($return === false) {
echo I18n::translate($singular, $plural, null, LC_MESSAGES, $count);
echo I18n::translate($singular, $plural, null, 6, $count);
} else {
return I18n::translate($singular, $plural, null, LC_MESSAGES, $count);
return I18n::translate($singular, $plural, null, 6, $count);
}
}
/**
Expand Down Expand Up @@ -679,9 +672,9 @@ function __dn($domain, $singular, $plural, $count, $return = false) {
}

if ($return === false) {
echo I18n::translate($singular, $plural, $domain, LC_MESSAGES, $count);
echo I18n::translate($singular, $plural, $domain, 6, $count);
} else {
return I18n::translate($singular, $plural, $domain, LC_MESSAGES, $count);
return I18n::translate($singular, $plural, $domain, 6, $count);
}
}
/**
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/i18n.php
Expand Up @@ -123,7 +123,7 @@ function &getInstance() {
* @return string translated strings.
* @access public
*/
function translate($singular, $plural = null, $domain = null, $category = LC_MESSAGES, $count = null) {
function translate($singular, $plural = null, $domain = null, $category = 6, $count = null) {
$_this =& I18n::getInstance();

if (strpos($singular, "\r\n") !== false) {
Expand Down
24 changes: 12 additions & 12 deletions cake/tests/cases/basics.test.php
Expand Up @@ -388,16 +388,16 @@ function test__dn() {
function test__c() {
Configure::write('Config.language', 'rule_1_po');

$result = __c('Plural Rule 1', LC_MESSAGES, true);
$result = __c('Plural Rule 1', 6, true);
$expected = 'Plural Rule 1 (translated)';
$this->assertEqual($result, $expected);

$result = __c('Plural Rule 1 (from core)', LC_MESSAGES, true);
$result = __c('Plural Rule 1 (from core)', 6, true);
$expected = 'Plural Rule 1 (from core translated)';
$this->assertEqual($result, $expected);

ob_start();
__c('Plural Rule 1 (from core)', LC_MESSAGES);
__c('Plural Rule 1 (from core)', 6);
$result = ob_get_clean();
$expected = 'Plural Rule 1 (from core translated)';
$this->assertEqual($result, $expected);
Expand All @@ -411,24 +411,24 @@ function test__c() {
function test__dc() {
Configure::write('Config.language', 'rule_1_po');

$result = __dc('default', 'Plural Rule 1', LC_MESSAGES, true);
$result = __dc('default', 'Plural Rule 1', 6, true);
$expected = 'Plural Rule 1 (translated)';
$this->assertEqual($result, $expected);

$result = __dc('default', 'Plural Rule 1 (from core)', LC_MESSAGES, true);
$result = __dc('default', 'Plural Rule 1 (from core)', 6, true);
$expected = 'Plural Rule 1 (from core translated)';
$this->assertEqual($result, $expected);

$result = __dc('core', 'Plural Rule 1', LC_MESSAGES, true);
$result = __dc('core', 'Plural Rule 1', 6, true);
$expected = 'Plural Rule 1';
$this->assertEqual($result, $expected);

$result = __dc('core', 'Plural Rule 1 (from core)', LC_MESSAGES, true);
$result = __dc('core', 'Plural Rule 1 (from core)', 6, true);
$expected = 'Plural Rule 1 (from core translated)';
$this->assertEqual($result, $expected);

ob_start();
__dc('default', 'Plural Rule 1 (from core)', LC_MESSAGES);
__dc('default', 'Plural Rule 1 (from core)', 6);
$result = ob_get_clean();
$expected = 'Plural Rule 1 (from core translated)';
$this->assertEqual($result, $expected);
Expand All @@ -442,20 +442,20 @@ function test__dc() {
function test__dcn() {
Configure::write('Config.language', 'rule_1_po');

$result = __dcn('default', '%d = 1', '%d = 0 or > 1', 0, LC_MESSAGES, true);
$result = __dcn('default', '%d = 1', '%d = 0 or > 1', 0, 6, true);
$expected = '%d = 0 or > 1 (translated)';
$this->assertEqual($result, $expected);

$result = __dcn('default', '%d = 1 (from core)', '%d = 0 or > 1 (from core)', 1, LC_MESSAGES, true);
$result = __dcn('default', '%d = 1 (from core)', '%d = 0 or > 1 (from core)', 1, 6, true);
$expected = '%d = 1 (from core translated)';
$this->assertEqual($result, $expected);

$result = __dcn('core', '%d = 1', '%d = 0 or > 1', 0, LC_MESSAGES, true);
$result = __dcn('core', '%d = 1', '%d = 0 or > 1', 0, 6, true);
$expected = '%d = 0 or > 1';
$this->assertEqual($result, $expected);

ob_start();
__dcn('default', '%d = 1 (from core)', '%d = 0 or > 1 (from core)', 1, LC_MESSAGES);
__dcn('default', '%d = 1 (from core)', '%d = 0 or > 1 (from core)', 1, 6);
$result = ob_get_clean();
$expected = '%d = 1 (from core translated)';
$this->assertEqual($result, $expected);
Expand Down

0 comments on commit 508f065

Please sign in to comment.