Restore "Add VlantagApi Functional Component""
[ccsdk/apps.git] / ms / vlantag-api / src / main / resources / META-INF / resources / swagger-ui / dist / lang / translator.js
1 'use strict';\r
2 \r
3 /**\r
4  * Translator for documentation pages.\r
5  *\r
6  * To enable translation you should include one of language-files in your index.html\r
7  * after <script src='lang/translator.js' type='text/javascript'></script>.\r
8  * For example - <script src='lang/ru.js' type='text/javascript'></script>\r
9  *\r
10  * If you wish to translate some new texsts you should do two things:\r
11  * 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.\r
12  * 2. Mark that text it templates this way <anyHtmlTag data-sw-translate>New Phrase</anyHtmlTag> or <anyHtmlTag data-sw-translate value='New Phrase'/>.\r
13  * The main thing here is attribute data-sw-translate. Only inner html, title-attribute and value-attribute are going to translate.\r
14  *\r
15  */\r
16 window.SwaggerTranslator = {\r
17 \r
18     _words:[],\r
19 \r
20     translate: function(sel) {\r
21       var $this = this;\r
22       sel = sel || '[data-sw-translate]';\r
23 \r
24       $(sel).each(function() {\r
25         $(this).html($this._tryTranslate($(this).html()));\r
26 \r
27         $(this).val($this._tryTranslate($(this).val()));\r
28         $(this).attr('title', $this._tryTranslate($(this).attr('title')));\r
29       });\r
30     },\r
31 \r
32     _tryTranslate: function(word) {\r
33       return this._words[$.trim(word)] !== undefined ? this._words[$.trim(word)] : word;\r
34     },\r
35 \r
36     learn: function(wordsMap) {\r
37       this._words = wordsMap;\r
38     }\r
39 };\r