Internationalization

Accessing Resource Bundles

formatMessage(String bundleName, String key {, parameters ...} )

Gets the value of key from a resource bundle (bundleName) based on the current Locale. When one or more parameters are specified, it formats a message through MessageFormat::format() method.


formatMessage("pnuts/lang/pnuts", "autoload.failed")

   ==> ResourceBundle::getBundle("pnuts/lang/pnuts", Locale::getDefault()).getObject("autoload.failed")

formatMessage("pnuts/lang/pnuts", "autoload.failed", "foo.pnut")

   ==> MessageFormat::format(
           ResourceBundle::getBundle("pnuts/lang/pnuts", LC).getObject("autoload.failed"),
          ["foo.pnut"])

Locale-sensitive Number Formats

formatNumber (Number number {, int fmin }) or
(Number number {, int imin , int imax , int fmin , int fmax } )
formatCurrency (Number number {, int fmin }) or
(Number number {, int imin , int imax , int fmin , int fmax } )
formatPercent (Number number {, int fmin }) or
(Number number {, int imin , int imax , int fmin , int fmax } )

Gets a formatted number, currency, and percent number respectively.

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
fmt1 = formatNumber(12345)
fmt2 = formatCurrency(12345)
fmt3 = formatPercent(0.12, 3)
formatDate ( Date aDate {, String style } )
formatTime ( Date aDate {, String style } )
formatDateTime ( Date aDate {, String style {, String style }} )

Gets a formatted date, time, and both respectively.

If style is omitted "DEFAULT" is passed implicitly. style can be one of the followings (case-insensitive):

formatDate(Date(), "full")
formatTime(Date(), "short")
formatDateTime(Date())
setFormatLocale(Locale locale )

Changes the Locale with which formatXXXX function formats objects.


Back