summaryrefslogtreecommitdiffstats
path: root/src/main/resources/META-INF/resources/swagger/lang/translator.js
diff options
context:
space:
mode:
authorTait,Trevor(rt0435) <rtait@amdocs.com>2018-10-03 15:08:34 -0400
committerMohammadreza Pasandideh <mohammadreza.pasandideh@amdocs.com>2018-10-09 15:36:22 -0400
commita2423cf3ba54da34bb865befd44d56bbb925a94b (patch)
tree6d4ac22b24f3f33087edc3e7c077ef3d6ad96469 /src/main/resources/META-INF/resources/swagger/lang/translator.js
parent2fb09922810847108464ba52e5b68907d5176e7a (diff)
POMBA: SDNC Context Builder
Initial code for POMBA: SDNC Context Builder Issue-ID: LOG-520 Change-Id: I6b06561b9050acc83b0c2b18b21c94f0f13f63e4 Signed-off-by: Tait,Trevor(rt0435) <rtait@amdocs.com>
Diffstat (limited to 'src/main/resources/META-INF/resources/swagger/lang/translator.js')
-rw-r--r--src/main/resources/META-INF/resources/swagger/lang/translator.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/main/resources/META-INF/resources/swagger/lang/translator.js b/src/main/resources/META-INF/resources/swagger/lang/translator.js
new file mode 100644
index 0000000..591f6d4
--- /dev/null
+++ b/src/main/resources/META-INF/resources/swagger/lang/translator.js
@@ -0,0 +1,39 @@
+'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 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 <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;
+ }
+};