Categories

.dictParse()

Categories: Utilities | Internationalisation

.dictParse( dict, deep )Returns: jQuery

Plugin: jQuery.dict

Description: Parse translations for each element in the set fo matched elements.

  • .dictParse( dict, deep )

    version added: 1.0

    dict   A dictionary object.

    deep   A boolean indication whether to parse all contained elements of each element in the set of matched elements.

  • .dictParse( dictname, deep, [ options ] )

    version added: 1.0

    dictname   The name of the dictionary.

    deep   A boolean indication whether to parse all contained elements of each element in the set of matched elements.

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

This method is using jQuery.dict() to parse translations in a DOM structure.

  • Run dictionary parser for an element.

    HTML:
    <div id="translate">
      {Hello}
      <ul>
        <li>{ItemA}</li>
        <li>{ItemA}</li>
      </ul>
    </div>
    Code:
    // The example dictionary must be already defined.
    $('#translate').dictParse( 'example', {region:'de'} );
    Results:
    <div id="translate">
      Hallo
      <ul>
        <li>{ItemA}</li>
        <li>{ItemA}</li>
      </ul>
    </div>
  • Run dictionary parser for an element and contained elements.

    HTML:
    <div id="translate">
      {Hello}
      <ul>
        <li>{ItemA}</li>
        <li>{ItemB}</li>
      </ul>
    </div>
    Code:
    // The example dictionary must be already defined.
    $('#translate').dictParse( 'example', true, {region:'de'} );
    Results:
    <div id="translate">
      Hallo
      <ul>
        <li>Artikel A</li>
        <li>Artikel B</li>
      </ul>
    </div>
  • 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