Categories

jQuery.i18n()

Categories: Utilities | Internationalisation

jQuery.i18n( type, value, [ options ] )Returns: String

Plugin: jQuery.i18n

Description: Get a formated date/number from Date/Number object.

  • jQuery.i18n( type, value, [ options ] )

    version added: 1.0

    type   A type for a date/number.

    value   An Date/Number object.

    options   A set of key/value pairs that configure the i18n call. A default are set for any option by jQuery.i18n.settings.

The jQuery.i18n() method is a shortcut to format a date or number and supports only the standart types.

Standart types with their full formats (Example: en):
  • date or dM/d/yyyy
  • dateLong or D => dddd, MMMM dd, yyyy>>
  • dateLong-time or fdddd, MMMM dd, yyyy h:mm tt
  • dateLong-timeLong or Fdddd, MMMM dd, yyyy h:mm:ss tt
  • date-time or lM/d/yyyy h:mm tt
  • date-timeLong or LM/d/yyyy h:mm:ss tt
  • time or th:mm tt
  • timeLong or Th:mm:ss tt
  • currency or cc2
  • number or nn2
  • percent or pp2
  • Get a formated date.

    Code:
    $.i18n( "d", new Date(2011, 1, 15) );
    
    // or
    
    $.i18n( "date", new Date(2011, 1, 15) );
    Results:
    2/15/2011
  • Get a formated date in german.

    Code:
    $.i18n( "d", new Date(2011, 1, 15), {region:"de"} );
    Results:
    15.02.2011
  • Get a formated number with percent.

    Code:
    $.i18n( "p", 25.50 );
    Results:
    25.50 %
  • Get a formated number with percent in german.

    Code:
    $.i18n( "p", 25.50, {region:"de"} );
    Results:
    25,50 %

jQuery.i18n( type, value, [ options ] )Returns: String

Plugin: jQuery.i18n

Description: Get a Date/Number object from formated string.

  • jQuery.i18n( type, value, [ options ] )

    version added: 1.0

    type   A type for a date/number.

    value   An date or a number string.

    options   A set of key/value pairs that configure the i18n call. A default are set for any option by jQuery.i18n.settings.

The jQuery.i18n() method is a shortcut to get a Date/Number object from a formated string and supports only the standart types.

Standart types with their full formats (Example: en):
  • date or dM/d/yyyy
  • dateLong or D => dddd, MMMM dd, yyyy>>
  • dateLong-time or fdddd, MMMM dd, yyyy h:mm tt
  • dateLong-timeLong or Fdddd, MMMM dd, yyyy h:mm:ss tt
  • date-time or lM/d/yyyy h:mm tt
  • date-timeLong or LM/d/yyyy h:mm:ss tt
  • time or th:mm tt
  • timeLong or Th:mm:ss tt
  • currency or cc2
  • number or nn2
  • percent or pp2
  • Get a Date object from date string.

    Code:
    $.i18n( "d", "2/15/2011" );
    
    // or
    
    $.i18n( "date", "2/15/2011" );
    Results:
    Date object // Tue Feb 15 2011 00:00:00 GMT+0100 (CET)
  • Get a Date object from german date string.

    Code:
    $.i18n( "d", "15.02.2011", {region:"de"} );
    Results:
    Date object // Tue Feb 15 2011 00:00:00 GMT+0100 (CET)
  • Get a Number object from percent string.

    Code:
    $.i18n( "p", "25.50 %" );
    Results:
    25.50
  • Get a Number object from german percent string.

    Code:
    $.i18n( "p", "25,50 %", {region:"de"} );
    Results:
    25.50
  • calendar

    version added: 1.0

    An available calender of the selected region.

    Default: 'standart'

  • currency

    version added: 1.0

    An other ISO 4217 three-letter uppercase currency code than the default of the selected region.

  • region

    version added: 1.0

    A combination of an ISO 639 two-letter lowercase culture code for the language (and a two-letter uppercase code for the country or region).

    Default: 'en'