diff --git a/.gitignore b/.gitignore
index d6ef6414..6b98d126 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,12 +1,13 @@
-.DS_STORE
-*.ipr
-*.iml
-*.iws
-web/
-lib/*.zip
-version.properties
-.sass-cache
-swagger-ui.sublime-workspace
-.idea
-.project
-node_modules/*
+.DS_STORE
+*.ipr
+*.iml
+*.iws
+web/
+lib/*.zip
+version.properties
+.sass-cache
+swagger-ui.sublime-workspace
+.idea
+.project
+node_modules/*
+/nbproject/private/
\ No newline at end of file
diff --git a/README.md b/README.md
index 3d52019a..252374e9 100644
--- a/README.md
+++ b/README.md
@@ -57,6 +57,7 @@ Once you open the Swagger UI, it will load the [Swagger Petstore](http://petstor
You may choose to customize Swagger UI for your organization. Here is an overview of whats in its various directories:
- dist: Contains a distribution which you can deploy on a server or load from your local machine.
+- dist/lang: The swagger localisation
- lib: Contains javascript dependencies which swagger-ui depends on
- node_modules: Contains node modules which swagger-ui uses for its development.
- src
@@ -124,6 +125,31 @@ window.authorizations.add("key", new ApiKeyAuthorization("Authorization", "XXXX"
Note! You can pass multiple header params on a single request, just use unique names for them (`key` is used in the above example).
+### Localisation and translation
+The localisation files are in the dist/lang directory.
+
+To enable translation you should append next two lines in your swagger's index.html (or another entry point you use)
+```html
+
+
+```
+The first line script is a translator and the second one is your language lexemes.
+
+If you wish to append support for new language you just need to create lang/your_lang.js and fill it like it's done in existing files.
+
+To append new lexemex for translation you shoul do two things:
+1. Add lexeme into the language file.
+ Example of new line: "new sentence":"translation of new sentence".
+2. Mark this lexeme in source html with attribute data-sw-translate.
+ Example of changed source:
+```html
+ new sentence
+ or
+```
+.
+
+At this moment only inner html, title-attribute and value-attribute are going to be translated.
+
## CORS Support
CORS is a technique to prevent websites from doing bad things with your personal data. Most browsers + javascript toolkits not only support CORS but enforce it, which has implications for your API server which supports Swagger.
diff --git a/dist/lib/swagger-client.js b/dist/lib/swagger-client.js
index 98bbad78..d5ca3135 100644
--- a/dist/lib/swagger-client.js
+++ b/dist/lib/swagger-client.js
@@ -9,7 +9,7 @@ var ArrayModel = function(definition) {
this.name = "arrayModel";
this.definition = definition || {};
this.properties = [];
-
+
var requiredFields = definition.enum || [];
var innerType = definition.items;
if(innerType) {
@@ -301,7 +301,7 @@ PrimitiveModel.prototype.getMockSignature = function(modelsToIgnore) {
}
return returnVal;
};
-/**
+/**
* Resolves a spec's remote references
*/
var Resolver = function (){};
@@ -1721,7 +1721,7 @@ Property.prototype.toString = function() {
}
- var options = '';
+ var options = '';
var isArray = this.schema.type === 'array';
var type;
@@ -1783,11 +1783,11 @@ Property.prototype.toString = function() {
}
options += optionHtml('Enum', enumString);
- }
+ }
if (options.length > 0)
str = '' + str + '| ' + this.name + ' |
' + options + '
';
-
+
return str;
};
@@ -1882,7 +1882,7 @@ SwaggerClient.prototype.finish = function() {
this.isBuilt = true;
this.selfReflect();
this.success();
- }
+ }
};
SwaggerClient.prototype.buildFrom1_1Spec = function (response) {
@@ -2173,11 +2173,11 @@ SwaggerResource.prototype.addOperations = function (resource_path, ops, consumes
o.summary,
o.notes,
type,
- responseMessages,
- this,
- consumes,
- produces,
- o.authorizations,
+ responseMessages,
+ this,
+ consumes,
+ produces,
+ o.authorizations,
o.deprecated);
this.operations[op.nickname] = op;
@@ -2674,15 +2674,15 @@ SwaggerOperation.prototype.urlify = function (args) {
param = params[i];
if(param.paramType === 'query') {
if (queryParams !== '')
- queryParams += '&';
+ queryParams += '&';
if (Array.isArray(param)) {
- var output = '';
- for(j = 0; j < param.length; j++) {
- if(j > 0)
- output += ',';
- output += encodeURIComponent(param[j]);
- }
- queryParams += encodeURIComponent(param.name) + '=' + output;
+ var output = '';
+ for(j = 0; j < param.length; j++) {
+ if(j > 0)
+ output += ',';
+ output += encodeURIComponent(param[j]);
+ }
+ queryParams += encodeURIComponent(param.name) + '=' + output;
}
else {
if (typeof args[param.name] !== 'undefined') {
@@ -2751,7 +2751,7 @@ SwaggerOperation.prototype.asCurl = function (args) {
var results = [];
var i;
- var headers = SwaggerRequest.prototype.setHeaders(args, {}, this);
+ var headers = SwaggerRequest.prototype.setHeaders(args, {}, this);
for(i = 0; i < this.parameters.length; i++) {
var param = this.parameters[i];
if(param.paramType && param.paramType === 'header' && args[param.name]) {
diff --git a/lib/swagger-client.js b/lib/swagger-client.js
index 98bbad78..d5ca3135 100644
--- a/lib/swagger-client.js
+++ b/lib/swagger-client.js
@@ -9,7 +9,7 @@ var ArrayModel = function(definition) {
this.name = "arrayModel";
this.definition = definition || {};
this.properties = [];
-
+
var requiredFields = definition.enum || [];
var innerType = definition.items;
if(innerType) {
@@ -301,7 +301,7 @@ PrimitiveModel.prototype.getMockSignature = function(modelsToIgnore) {
}
return returnVal;
};
-/**
+/**
* Resolves a spec's remote references
*/
var Resolver = function (){};
@@ -1721,7 +1721,7 @@ Property.prototype.toString = function() {
}
- var options = '';
+ var options = '';
var isArray = this.schema.type === 'array';
var type;
@@ -1783,11 +1783,11 @@ Property.prototype.toString = function() {
}
options += optionHtml('Enum', enumString);
- }
+ }
if (options.length > 0)
str = '' + str + '| ' + this.name + ' |
' + options + '
';
-
+
return str;
};
@@ -1882,7 +1882,7 @@ SwaggerClient.prototype.finish = function() {
this.isBuilt = true;
this.selfReflect();
this.success();
- }
+ }
};
SwaggerClient.prototype.buildFrom1_1Spec = function (response) {
@@ -2173,11 +2173,11 @@ SwaggerResource.prototype.addOperations = function (resource_path, ops, consumes
o.summary,
o.notes,
type,
- responseMessages,
- this,
- consumes,
- produces,
- o.authorizations,
+ responseMessages,
+ this,
+ consumes,
+ produces,
+ o.authorizations,
o.deprecated);
this.operations[op.nickname] = op;
@@ -2674,15 +2674,15 @@ SwaggerOperation.prototype.urlify = function (args) {
param = params[i];
if(param.paramType === 'query') {
if (queryParams !== '')
- queryParams += '&';
+ queryParams += '&';
if (Array.isArray(param)) {
- var output = '';
- for(j = 0; j < param.length; j++) {
- if(j > 0)
- output += ',';
- output += encodeURIComponent(param[j]);
- }
- queryParams += encodeURIComponent(param.name) + '=' + output;
+ var output = '';
+ for(j = 0; j < param.length; j++) {
+ if(j > 0)
+ output += ',';
+ output += encodeURIComponent(param[j]);
+ }
+ queryParams += encodeURIComponent(param.name) + '=' + output;
}
else {
if (typeof args[param.name] !== 'undefined') {
@@ -2751,7 +2751,7 @@ SwaggerOperation.prototype.asCurl = function (args) {
var results = [];
var i;
- var headers = SwaggerRequest.prototype.setHeaders(args, {}, this);
+ var headers = SwaggerRequest.prototype.setHeaders(args, {}, this);
for(i = 0; i < this.parameters.length; i++) {
var param = this.parameters[i];
if(param.paramType && param.paramType === 'header' && args[param.name]) {