Locale improvements: add language code to localization functions

Jose Reyero - May 29, 2007 - 12:16
Project:Drupal
Version:6.x-dev
Component:language system
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

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.

AttachmentSizeStatusTest resultOperations
locale_langcode_01.patch12.18 KBIgnoredNoneNone

#1

Gábor Hojtsy - May 29, 2007 - 14:40
Status:needs review» fixed

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!

AttachmentSizeStatusTest resultOperations
locale_langcode_02.patch13.21 KBIgnoredNoneNone

#2

Anonymous - June 12, 2007 - 14:47
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.