From 44bc2eab566954463cd0b2b4b6e525ec9ac058c4 Mon Sep 17 00:00:00 2001 From: Josh Ponelat Date: Tue, 16 Jun 2015 11:57:38 +0200 Subject: [PATCH] build with translator support --- dist/index.html | 18 ++++++++++++-- dist/lang/en.js | 52 +++++++++++++++++++++++++++++++++++++++++ dist/lang/ru.js | 52 +++++++++++++++++++++++++++++++++++++++++ dist/lang/translator.js | 39 +++++++++++++++++++++++++++++++ dist/swagger-ui.js | 44 ++++++++++++++++++---------------- dist/swagger-ui.min.js | 27 ++++++++++----------- 6 files changed, 195 insertions(+), 37 deletions(-) create mode 100644 dist/lang/en.js create mode 100644 dist/lang/ru.js create mode 100644 dist/lang/translator.js diff --git a/dist/index.html b/dist/index.html index a6904d0f..8fe50d02 100644 --- a/dist/index.html +++ b/dist/index.html @@ -21,6 +21,11 @@ + + + + + . + * For example - + * + * If you wish to translate some new texsts 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 New Phrase or . + * 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; + var 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; + } +}; diff --git a/dist/swagger-ui.js b/dist/swagger-ui.js index cb460bbb..7b4c86ce 100644 --- a/dist/swagger-ui.js +++ b/dist/swagger-ui.js @@ -8,12 +8,12 @@ this["Handlebars"]["templates"] = this["Handlebars"]["templates"] || {}; this["Handlebars"]["templates"]["apikey_button_view"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) { var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression; - return "\n
\n
\n
\n \n \n
\n
\n\n"; },"useData":true}); this["Handlebars"]["templates"]["basic_auth_button_view"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) { - return "
\n
\n
\n
\n \n
\n \n \n
\n
\n\n"; + return "
\n
\n
\n
\n \n
\n \n \n
\n
\n\n"; },"useData":true}); this["Handlebars"]["templates"]["content_type"] = Handlebars.template({"1":function(depth0,helpers,partials,data) { var stack1, buffer = ""; @@ -319,15 +319,15 @@ this["Handlebars"]["templates"]["main"] = Handlebars.template({"1":function(dept var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression; return ""; + + "\" data-sw-translate>Terms of service"; },"6":function(depth0,helpers,partials,data) { var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression; - return ""; },"12":function(depth0,helpers,partials,data) { var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression; return "\n"; },"16":function(depth0,helpers,partials,data) { var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression; - return "

Response Class (Status " + return "

Response Class (Status " + escapeExpression(((helper = (helper = helpers.successCode || (depth0 != null ? depth0.successCode : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"successCode","hash":{},"data":data}) : helper))) + ")

\n

\n
\n
\n"; },"18":function(depth0,helpers,partials,data) { @@ -417,7 +417,7 @@ this["Handlebars"]["templates"]["operation"] = Handlebars.template({"1":function },"24":function(depth0,helpers,partials,data) { return " \n"; },"26":function(depth0,helpers,partials,data) { - return "

Request Headers

\n
\n"; + return "

Request Headers

\n
\n"; },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) { var stack1, helper, options, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, blockHelperMissing=helpers.blockHelperMissing, buffer = "\n
    \n
  • Response Body\n
    \n

    Response Code

    \n
    \n

    Response Headers

    \n
    \n
\n \n \n \n"; + return buffer + "

Response Body

\n
\n

Response Code

\n
\n

Response Headers

\n
\n \n \n \n \n"; },"useData":true}); this["Handlebars"]["templates"]["param_list"] = Handlebars.template({"1":function(depth0,helpers,partials,data) { return " required"; @@ -787,7 +787,7 @@ this["Handlebars"]["templates"]["resource"] = Handlebars.template({"1":function( var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression; return "
  • \n Raw\n
  • \n"; + + "' data-sw-translate>Raw\n \n"; },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) { var stack1, helper, options, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, blockHelperMissing=helpers.blockHelperMissing, buffer = "
    \n

    \n Show/Hide\n \n
  • \n Show/Hide\n
  • \n
  • \n \n List Operations\n \n
  • \n
  • \n \n List Operations\n \n
  • \n
  • \n \n Expand Operations\n \n
  • \n"; + + "\" data-sw-translate>\n Expand Operations\n \n \n"; stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.url : depth0), {"name":"if","hash":{},"fn":this.program(3, data),"inverse":this.noop,"data":data}); if (stack1 != null) { buffer += stack1; } return buffer + " \n

    \n