Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

translator.js 1.4 KiB

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