This patch adds an optional language code parameter to all localization functions that were missing it. This is required to be able to run multilingual requests, feature already supported by 't(' function.
- format_size
- format_interval
- format_date
- format_plural
- locale_get_plural

Also, a pair small related improvements
- Added a $property parameter to language_default() to be able to get single properties saving some code. I.e. to get the default language code: language_default('language'), this simplifies the code a little bit
- Changed hardcoded default language parameter 'en' in format_rss_items. We are not assuming a default language anywhere else than in language_default. Also changed the variable name to $langcode, which is more adequate.

All this looks like quite simple and sraightforward unless I've missed anything.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Gábor Hojtsy’s picture

Status: Needs review » Fixed
FileSize
13.21 KB

I applied this patch to one of my local test sites and tried some of the functionality (plurals, intervals). It worked nicely.
By reviewing the code, I also noticed a few smaller issues, which I fixed:

- t() should have $args default to array() and not 0, it is an array after all (as in other functions expecting an array)
- modifed the t() calls affected
- fixed locale_get_plural(), where you did not change the variable name in the eval()

Committed the attached patch. Thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)