l10n
Summary
Formats misc. numbers (times, dates, currencies, numbers, etc.).Usage
input|l10n( type [, locale [, symbol ] ] )
Parameters
Name | Type | Description | Required |
---|---|---|---|
type | string | The format that should be used. | Yes. |
locale | string | The locale that should be used (when type is set to "currency"). | No. |
symbol | string | The currency symbol that should be used (when type is set to "currency"). | No. |
Returns
A string containing a formatted version of the input parameter.Description
This operator formats/localizes miscellaneous numeric values according to the current locale settings. The value that should be formatted must be input using the input parameter. The "type" parameter must be used to select the desired format. The following list reveals the available formats/types.
- time
- shorttime
- date
- shortdate
- datetime
- shortdatetime
- currency
- clean_currency
- number
In addition, the operator also formats numeric values according to the specified "locale" and "symbol" parameters when the "type" parameter is set to "currency".
Examples
Example 1
{def $number=1234.567 $timestamp=currentdate()} time: {$timestamp|l10n( 'time' )} shorttime: {$timestamp|l10n( 'shorttime' )} date: {$timestamp|l10n( 'date' )} shortdate: {$timestamp|l10n( 'shortdate' )} datetime: {$timestamp|l10n( 'datetime' )} shortdatetime: {$timestamp|l10n( 'shortdatetime' )} currency: {$number|l10n( 'currency' )} clean_currency: {$number|l10n( 'clean_currency' )} number: {$number|l10n( 'number' )}
If the current locale is "eng-GB", the following output will be produced:
time : 1:46:05 pm
shorttime : 1:46 pm
date : Friday 06 February 2004
shortdate : 06/02/2004
datetime : Friday 06 February 2004 1:46:05 pm
shortdatetime : 06/02/2004 1:46 pm
currency : £ 1,234.57
clean_currency : 1,234.57
number : 1,234.57
Example 2
{def $price=1234.57} The price in local currency : {$price|l10n( 'currency' )} <br /> The price in Norwegian Krone : {$price|l10n( 'currency', 'nor-NO' )} <br /> The price in Norwegian Krone with specified symbol : {$price|l10n( 'currency', 'nor-NO', 'nok' )}
If the current locale is "eng-GB", the following output will be produced:
The price in local currency : £ 1,234.57
The price in Norwegian Krone : kr 1.234,57
The price in Norwegian Krone with specified symbol : nok 1.234,57
Balazs Halasy (05/02/2004 10:36 am)
Svitlana Shatokhina (05/05/2006 8:09 am)
Comments
Get rid of whitespace
Wednesday 24 January 2007 1:16:53 pm
Fabricio
Is it possible to get rid of whitespace after currency sign??
currently : £ 1,234.57
can it be : £1,234.57
Re: Get rid of whitespace
Wednesday 13 June 2007 9:40:14 am
AtR
But since these files are overwritten each time you upgrade, it's recommended that you create your own locale override ala eng-GB@my-settings.ini and then set locale in site.ini regional settings to something like: Locale=eng-GB@my-settings