Sha256: 457ba9b83d81780958ed1d93fa5f49e491db7c9a25cd5e9663e12a61068ec645

Contents?: true

Size: 1.39 KB

Versions: 54

Compression:

Stored size: 1.39 KB

Contents

'use strict';

/**
 * Translator for documentation pages.
 *
 * To enable translation you should include one of language-files in your index.html
 * after <script src='lang/translator.js' type='text/javascript'></script>.
 * For example - <script src='lang/ru.js' type='text/javascript'></script>
 *
 * If you wish to translate some new texts you should do two things:
 * 1. Add a new phrase pair ("New Phrase": "New Translation") into your language file (for example lang/ru.js). It will be great if you add it in other language files too.
 * 2. Mark that text it templates this way <anyHtmlTag data-sw-translate>New Phrase</anyHtmlTag> or <anyHtmlTag data-sw-translate value='New Phrase'/>.
 * The main thing here is attribute data-sw-translate. Only inner html, title-attribute and value-attribute are going to translate.
 *
 */
window.SwaggerTranslator = {

    _words:[],

    translate: function(sel) {
      var $this = this;
      sel = sel || '[data-sw-translate]';

      $(sel).each(function() {
        $(this).html($this._tryTranslate($(this).html()));

        $(this).val($this._tryTranslate($(this).val()));
        $(this).attr('title', $this._tryTranslate($(this).attr('title')));
      });
    },

    _tryTranslate: function(word) {
      return this._words[$.trim(word)] !== undefined ? this._words[$.trim(word)] : word;
    },

    learn: function(wordsMap) {
      this._words = wordsMap;
    }
};

Version data entries

54 entries across 54 versions & 7 rubygems

Version Path
swaggard-1.5.1 app/assets/javascripts/swaggard/translator.js
swaggard-1.5.0 app/assets/javascripts/swaggard/translator.js
swagger_ui_engine_rails7-1.2.5 app/assets/javascripts/swagger_ui_engine/lang/translator.js
swagger_ui_engine_rails7-1.2.4 app/assets/javascripts/swagger_ui_engine/lang/translator.js
swagger_ui_engine_rails7-1.2.3 app/assets/javascripts/swagger_ui_engine/lang/translator.js
swagger_ui_engine_rails7-1.2.1 app/assets/javascripts/swagger_ui_engine/lang/translator.js
swaggard-1.4.0 app/assets/javascripts/swaggard/translator.js
swaggard-1.3.0 app/assets/javascripts/swaggard/translator.js
swaggard-1.2.0 app/assets/javascripts/swaggard/translator.js
swaggard-1.1.1 app/assets/javascripts/swaggard/translator.js
swaggard-1.1.0 app/assets/javascripts/swaggard/translator.js
swaggard-1.0.2 app/assets/javascripts/swaggard/translator.js
swaggard-1.0.1 app/assets/javascripts/swaggard/translator.js
swaggard-1.0.0 app/assets/javascripts/swaggard/translator.js
swagger_ui_engine-1.1.3 app/assets/javascripts/swagger_ui_engine/lang/translator.js
swagger_ui_engine-1.1.2 app/assets/javascripts/swagger_ui_engine/lang/translator.js
rswag-ui-1.6.0 vendor/assets/components/swagger-ui/lang/translator.js
swagger_ui_engine-1.1.1 app/assets/javascripts/swagger_ui_engine/lang/translator.js
rswag-ui-1.5.2 vendor/assets/components/swagger-ui/lang/translator.js
swagger_ui_engine-1.1.0 app/assets/javascripts/swagger_ui_engine/lang/translator.js