Categories

jQuery.dict()

Categories: Utilities | Internationalisation

jQuery.dict( dictname, [ options ] )Returns: Object

Plugin: jQuery.dict

Description: Get a dictionary object for translation.

  • jQuery.dict( dictname, [ options ] )

    version added: 1.0

    dictname   The name of the dictionary, optional including the namespace of region.

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

Get a dictionary object for translation.

  • Use a dictionary.

    Code:
    // The example dictionary is already defined.
    
    // use default region/language
    $.dict( 'example' );
    
    // use german
    $.dict( 'example', {region:'de'} );
    
    // use german
    $.dict( 'de:example' );
  • Translate keywords and parse text with a dict.

    Code:
    var obj = $.dict( 'de:example' );
    
    obj.translate('translation');
    // results: Übersetzung
    
    obj.parse('jQuery SDK {translation}');
    // results: jQuery SDK Übersetzung
  • region

    version added: 1.0

    A region/language to use for this dict.

    Default: 'en'

  • parser

    version added: 1.0

    A regular expression including 2 matches. First one is the key word with markers and the second one is the keywors to translate.

    Default: /(?:^|[^\{\$])(\{(.*?[^\\])\})/g

  • .translate()

    • .translate( keyword )

      version added: 1.0

      keyword   A keyword to translate.

    Get a translation for a keyword.

  • .parse()

    • .parse( text )

      version added: 1.0

      text   A text with keyword markers to translate.

    Parse a text with keyword markers and translate them with the dictionary.