Appended the checks of existing of translated attributes
This commit is contained in:
15
dist/lang/translator.js
vendored
15
dist/lang/translator.js
vendored
@@ -8,7 +8,7 @@
|
|||||||
* If you wish to translate some new texsts you should do two things:
|
* 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.
|
* 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'/>.
|
* 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.
|
* The main thing here is attribute data-sw-translate. Only inner text, title-attribute and value-attribute are going to translate.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
SwaggerTranslator = {
|
SwaggerTranslator = {
|
||||||
@@ -19,17 +19,26 @@ SwaggerTranslator = {
|
|||||||
var $this = this;
|
var $this = this;
|
||||||
$("[data-sw-translate]").each(
|
$("[data-sw-translate]").each(
|
||||||
function() {
|
function() {
|
||||||
$(this).html(
|
if ($(this).text() && $(this).children().length == 0) {
|
||||||
$this._tryTranslate($(this).html())
|
$(this).text(
|
||||||
|
$this._tryTranslate($(this).text())
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($(this).val()) {
|
||||||
$(this).val(
|
$(this).val(
|
||||||
$this._tryTranslate($(this).val())
|
$this._tryTranslate($(this).val())
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($(this).attr('title')) {
|
||||||
$(this).attr(
|
$(this).attr(
|
||||||
'title',
|
'title',
|
||||||
$this._tryTranslate($(this).attr('title'))
|
$this._tryTranslate($(this).attr('title'))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user