Lasso Soft Inc. > Home

[ locale ]

Method

The [locale] method creates a locale object which is used to provide the ability to format the output of various data in the manner specified by the locale.

The method requires one parameter which is the 2-letter code of the language of the locale (these codes follow the ISO-639 standard). Additionally [locale] accepts optional parameters which are, in order, the 2-letter country code (according to the ISO-3166 standard) and the variant code which allows further refinement to the locale. 

  • Syntax
  • Methods
  • Traits
locale( language, country, variant )
Has methods:
Examples
  • Beginner

Create a locale for formatting output

Use the [locale] method. This example creates a local for French Canada and shows how it affects various outputs.

Code

var( myLocale = locale('fr', 'CA'),
     myDollar = currency(22.99),
     myDecimal = 23.49,
     myDate = date )

'EN\t\t\tFR\n'
$myDollar+'\t\t'+$myLocale->format($myDollar)+'\n'
$myDecimal+'\t'+$myLocale->format($myDecimal)+'\n'
locale_canada->format($myDate)+'\t'+$myLocale->format($myDate)+'\n'

Result

EN			FR
$22.99		22,99 $
23.490000	23,49
2011-02-12	2011-02-12

Recent Comments

No Comments found

Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft