PageSourceSearch

https://spurno.github.io/js/i18n.js

js spurno.github.io collected 2026-10-03 09:59:03 UTC 3,121 bytes, 98 lines download raw bytes

1/* ============================================
2   SPurno Animation Studio v2 - i18n Translation
3   8 languages: EN, ES, FR, DE, PT, JA, ZH-CN, BN
4   ============================================ */
5(function() {
6  'use strict';
7
8  var LANG_LIST = {
9    en: { short: 'EN', label: 'English' },
10    es: { short: 'ES', label: 'Espa\u00F1ol' },
11    fr: { short: 'FR', label: 'Fran\u00E7ais' },
12    de: { short: 'DE', label: 'Deutsch' },
13    pt: { short: 'PT', label: 'Portugu\u00EAs' },
14    ja: { short: '\u65E5', label: '\u65E5\u672C\u8A9E' },
15    'zh-CN': { short: '\u4E2D', label: '\u7B80\u4F53\u4E2D\u6587' },
16    bn: { short: '\u09AC\u09BE', label: '\u09AC\u09BE\u0982\u09B2\u09BE' }
17  };
18
19  var SUPPORTED = ['en','es','fr','de','pt','ja','zh-CN','bn'];
20  var currentLang = 'en';
21
22  function getCookie(name) {
23    var m = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
24    return m ? decodeURIComponent(m[2]) : null;
25  }
26
27  function setCookie(name, value, days) {
28    var d = new Date();
29    d.setTime(d.getTime() + days * 86400000);
30    document.cookie = name + '=' + encodeURIComponent(value) + '; expires=' + d.toUTCString() + '; path=/';
31  }
32
33  function detectLanguage() {
34    var gt = getCookie('googtrans');
35    if (gt) {
36      var parts = gt.split('/');
37      if (parts.length >= 3 && SUPPORTED.indexOf(parts[2]) !== -1) {
38        return parts[2];
39      }
40    }
41    var ls = localStorage.getItem('v2Lang');
42    if (ls && SUPPORTED.indexOf(ls) !== -1) return ls;
43    return 'en';
44  }
45
46  function updateUI() {
47    var info = LANG_LIST[currentLang] || LANG_LIST.en;
48    document.querySelectorAll('.lang-btn').forEach(function(btn) {
49      btn.textContent = info.short;
50      btn.setAttribute('data-lang', currentLang);
51    });
52    document.querySelectorAll('.lang-option').forEach(function(opt) {
53      var lang = opt.getAttribute('data-language');
54      if (lang === currentLang) {
55        opt.classList.add('active');
56      } else {
57        opt.classList.remove('active');
58      }
59    });
60  }
61
62  window.changeLanguage = function(lang) {
63    if (!lang || SUPPORTED.indexOf(lang) === -1) return;
64    currentLang = lang;
65    setCookie('googtrans', '/en/' + lang, 365);
66    localStorage.setItem('v2Lang', lang);
67    updateUI();
68    location.reload();
69  };
70
71  document.addEventListener('DOMContentLoaded', function() {
72    currentLang = detectLanguage();
73
74    var meta = document.createElement('meta');
75    meta.name = 'google-translate-customization';
76    document.head.appendChild(meta);
77
78    var gtDiv = document.createElement('div');
79    gtDiv.id = 'google_translate_element';
80    gtDiv.style.display = 'none';
81    document.body.appendChild(gtDiv);
82
83    window.googleTranslateElementInit = function() {
84      new google.translate.TranslateElement({
85        pageLanguage: 'en',
86        includedLanguages: SUPPORTED.join(','),
87        autoDisplay: false
88      }, 'google_translate_element');
89    };
90
91    var s = document.createElement('script');
92    s.src = '//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit';
93    document.body.appendChild(s);
94
95    updateUI();
96  });
97
98})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.