Internationalization
locale()
- LC = locale()
- LC = locale(locale or localeName)
- LC = locale(language, country, [ variant ])
|
locale() creates a pnuts.util.LocaleAdapter object.
LC = locale()
LC_IT = locale("ITALY")
LC_JA = locale(Locale::JA)
LC_CF = locale("fr", "CA")
|
To get a Locale object from a LocaleAdatper object, call getLocale() of a LocaleAdatper object.
LC = locale()
LC . getLocale()
|
Accessing Resource Bundles
- LC . bundleName ( key , parameters... )
|
Gets the value of key from a resource bundle (bundleName) based on a LocaleAdapter (LC).
When one or more parameters are specified, it formats a message through MessageFormat::format() method.
LC = locale()
LC.pnuts("autoload.failed")
==> ResourceBundle::getBundle("pnuts", LC).getObject("autoload.failed")
LC.pnuts("autoload.failed", "foo.pnut")
==> MessageFormat::format(
ResourceBundle::getBundle("pnuts", LC).getObject("autoload.failed"),
["foo.pnut"])
|
Locale-sensitive Formats
- LC . number ( aNumber [, fmin | , imin, imax, fmin, fmax ])
- LC . currency ( aNumber [, fmin | , imin, imax, fmin, fmax ])
- LC . percent ( aNumber [, fmin | , imin, imax, fmin, fmax ])
|
- number
- Gets a formatted number
- currency
- Gets a formatted currency
- percent
- Gets a formatted percent number
imin, imax, fmin, fmax sets the number of digits for integer part
or fraction part.
When the value is -1 the default value is applied.
- imin
- the minimum integer digits for the NumberFormat
- imax
- the maximum integer digits for the NumberFormat
- fmin
- the minimum fraction digits for the NumberFormat
- fmax
- the maximum fraction digits for the NumberFormat
LC = locale()
fmt1 = LC.number(12345)
fmt2 = LC.currency(12345)
fmt3 = LC.percent(0.12, 3)
|
- LC . date ( [ aDate ] [, style ] )
- LC . time ( [ aDate ] [, style ] )
- LC . datetime ( [ aDate ] [, style [, style ]] )
|
- date
- Gets a formatted date
- time
- Gets a formatted time
- datetime
- Gets a formatted date and time
If aDate is omitted "new Date()" is passed implicitly.
If style is omitted DateFormat::DEFAULT is passed implicitly.
style can be one of the followings:
- "full"
- "long"
- "medium"
- "short"
LC = locale()
fmt4 = LC.date(date(), "full")
fmt5 = LC.time(date(), "short")
|