diff options
author | Gábor Hojtsy <gabor@hojtsy.hu> | 2007-05-29 14:37:49 +0000 |
---|---|---|
committer | Gábor Hojtsy <gabor@hojtsy.hu> | 2007-05-29 14:37:49 +0000 |
commit | 36e87e190c637338d6fd7d72132d5e74913a674d (patch) | |
tree | 06248a35fe00ef5d9251782c8439fcc41b367fa4 /modules | |
parent | af34a17925adaec3167d716d601701d80366d3ad (diff) | |
download | brdo-36e87e190c637338d6fd7d72132d5e74913a674d.tar.gz brdo-36e87e190c637338d6fd7d72132d5e74913a674d.tar.bz2 |
#147640 by Jose A Reyero with further cleanup by myself: add language code to localization functions
This makes it possible to call these functions with a given language code when sending emails to multiple users with different languages in a request for example.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/aggregator/aggregator.module | 2 | ||||
-rw-r--r-- | modules/locale/locale.module | 28 |
2 files changed, 19 insertions, 11 deletions
diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module index 806c59a95..4467b893a 100644 --- a/modules/aggregator/aggregator.module +++ b/modules/aggregator/aggregator.module @@ -1250,7 +1250,7 @@ function aggregator_page_rss() { $output .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; $output .= "<rss version=\"2.0\">\n"; - $output .= format_rss_channel(variable_get('site_name', 'Drupal') . ' ' . t('aggregator'), url('aggregator' . $url, array('absolute' => TRUE)), variable_get('site_name', 'Drupal') . ' - ' . t('aggregated feeds') . $title, $items, 'en'); + $output .= format_rss_channel(variable_get('site_name', 'Drupal') . ' ' . t('aggregator'), url('aggregator' . $url, array('absolute' => TRUE)), variable_get('site_name', 'Drupal') . ' - ' . t('aggregated feeds') . $title, $items); $output .= "</rss>\n"; drupal_set_header('Content-Type: application/rss+xml; charset=utf-8'); diff --git a/modules/locale/locale.module b/modules/locale/locale.module index 3a4e835c1..7d0933e8e 100644 --- a/modules/locale/locale.module +++ b/modules/locale/locale.module @@ -190,8 +190,7 @@ function locale_user($type, $edit, &$user, $category = NULL) { $languages = language_list('enabled'); $languages = $languages['1']; if ($user->language == '') { - $default = language_default(); - $user->language = $default->language; + $user->language = language_default('language'); } $names = array(); foreach ($languages as $langcode => $language) { @@ -367,26 +366,35 @@ function locale_refresh_cache() { * Returns plural form index for a specific number. * * The index is computed from the formula of this language. + * + * @param $count + * Number to return plural for. + * @param $langcode + * Optional language code to translate to a language other than + * what is used to display the page. */ -function locale_get_plural($count) { +function locale_get_plural($count, $langcode = NULL) { global $language; static $locale_formula, $plurals = array(); - if (!isset($plurals[$count])) { + $langcode = $langcode ? $langcode : $language->language; + + if (!isset($plurals[$langcode][$count])) { if (!isset($locale_formula)) { - $locale_formula = $language->formula; + $language_list = language_list(); + $locale_formula[$langcode] = $language_list[$langcode]->formula; } - if ($locale_formula) { + if ($locale_formula[$langcode]) { $n = $count; - $plurals[$count] = @eval("return intval($locale_formula);"); - return $plurals[$count]; + $plurals[$langcode][$count] = @eval('return intval('. $locale_formula[$langcode] .');'); + return $plurals[$langcode][$count]; } else { - $plurals[$count] = -1; + $plurals[$langcode][$count] = -1; return -1; } } - return $plurals[$count]; + return $plurals[$langcode][$count]; } |