Skip to content

Commit

Permalink
Fix date and time handling in language class:
Browse files Browse the repository at this point in the history
- make $_dates public to be accessible to Localisation Manager
- fix typo in date array
- correctly translate date strings without creating duplicates
- ignore case when localizing/standardizing dates
  • Loading branch information
nilshoerrmann committed Mar 27, 2011
1 parent ebd7e26 commit fda18f8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions symphony/lib/toolkit/class.lang.php
Expand Up @@ -175,7 +175,7 @@ public function remove($string) {
* Array of months and weekday for localized date output
* @var array
*/
private static $_dates;
public static $_dates;

/**
* Get dictionary
Expand Down Expand Up @@ -440,7 +440,7 @@ public static function load($path, $clear=false) {
'sec', 'second', 'min', 'minute', 'hour', 'day', 'fortnight', 'forthnight', 'month', 'year',
'secs', 'seconds', 'mins', 'minutes', 'hours', 'days', 'fortnights', 'forthnights', 'months', 'years',
'weekday', 'weekdays', 'week', 'weeks',
'first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eight', 'ninth', 'tenth', 'eleventh', 'twelfth', 'next', 'last', 'previous', 'this'
'first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth', 'eleventh', 'twelfth', 'next', 'last', 'previous', 'this'
);
foreach($dates as $date) {
self::$_dates[$date] = $date;
Expand All @@ -452,8 +452,8 @@ public static function load($path, $clear=false) {
self::$_dictionary->merge($dictionary);

// Add date translations
foreach(self::$_dates as $date) {
self::$_dates[$date] = __($date);
foreach(self::$_dates as $key => $value) {
self::$_dates[$key] = __($key);
}

}
Expand Down Expand Up @@ -518,7 +518,7 @@ public static function localizeDate($string) {
// Only translate dates in localized environments
if(self::isLocalized()) {
foreach(self::$_dates as $english => $locale) {
$string = preg_replace('/\b' . $english . '\b/', $locale, $string);
$string = preg_replace('/\b' . $english . '\b/i', $locale, $string);
}
}

Expand All @@ -540,7 +540,7 @@ public static function standardizeDate($string) {

// Translate names to English
foreach(self::$_dates as $english => $locale) {
$string = preg_replace('/\b' . $locale . '\b/', $english, $string);
$string = preg_replace('/\b' . $locale . '\b/i', $english, $string);
}

// Replace custom date and time separator with space:
Expand Down

0 comments on commit fda18f8

Please sign in to comment.