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.
Comment | File | Size | Author |
---|---|---|---|
#1 | locale_langcode_02.patch | 13.21 KB | Gábor Hojtsy |
locale_langcode_01.patch | 12.18 KB | Jose Reyero | |
Comments
Comment #1
Gábor HojtsyI 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!
Comment #2
(not verified) CreditAttribution: commented