10 examples of 'jquery translate' in JavaScript

Every line of 'jquery translate' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
64function translate(view, text) {
65 return view._props.translate ? view._props.translate(text) : text
66}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

46translate(key, lang) {
47 // If the language isn't specified and we have no overridden one, return the string passed.
48 if (!lang && !this._language) {
49 return key;
50 }
51
52 let setLanguage = lang || this._language;
53
54 let map = this.getTranslations(setLanguage);
55
56 if (!map) {
57 console.warn('I18N: No translation for key', key, 'using language', setLanguage);
58 return '';
59 }
60 return this._getTranslation(map, key);
61}
1export default function translate(lang, str) {
2 var trad = Locales
3 if (
4 typeof trad[lang] !== 'undefined' &&
5 trad[lang] !== null &&
6 typeof trad[lang][str] !== 'undefined' &&
7 trad[lang][str] !== null
8 ) {
9 return trad[lang][str]
10 }
11 return str
12}
105function before_translate(){
106 $('#rate_star').css("display",'none');
107 $('#rate_message').html("");
108 $('#rate_message').css("display",'none');
109}
30translate() {
31 var translated;
32
33 if (this.originText) {
34 translated = this.translator.translate(this.originText, this.$parse(this.plural)(this.scope), this.plural);
35 if (this.element.text() !== translated) {
36 this.element.text(translated);
37 }
38 }
39
40 if (this.originPlaceholder) {
41 translated = this.translator.translate(this.$parse(this.originPlaceholder)(this.scope));
42 if (this.element.attr('placeholder') !== translated) {
43 this.element.attr('placeholder', translated);
44 }
45 }
46}
57export function translate(key: any, locale: string) {
58 const language = locale.split('-')[0].toLowerCase();
59 let translations: any = TRANSLATIONS;
60
61 if (typeof key === 'string') {
62 const path = key.split('.');
63 if (path.length > 0) {
64 for (const segment of path) {
65 if (translations[segment]) {
66 translations = translations[segment];
67 } else {
68 translations = null;
69 break;
70 }
71 }
72 } else {
73 translations = null;
74 }
75 } else {
76 translations = key;
77 }
78
79 return translations && translations[language] ? translations[language] :
80 (language !== fallbackLanguage ? translate(key, fallbackLanguage + '-') : `[!${key}]`);
81}
171do_translate: function do_translate(dst_lang, text, callback) {
172 var url = 'http://translate.google.com/translate_a/t?client=t&text=' + encodeURIComponent(text) + '&hl=' + dst_lang + '&sl=auto&tl=' + dst_lang + '&multires=1&otf=2&ssel=0&tsel=0&uptl=' + dst_lang + '&alttl=en&sc=1';
173 var processData = function (data) {
174 var result = {};
175 result.responseData = {};
176 var res = JSON.parse(data.replace(/,,+/g, ','));
177 var translatedText = '';
178 if (res[0]) {
179 for (var i = 0; i < res[0].length; i += 1) {
180 translatedText += res[0][i][0];
181 }
182 }
183 result.lang = res[1];
184 result.responseStatus = 200;
185 result.responseData.translatedText = translatedText;
186 callback(result);
187 }
188 $.ajax({
189 url: url,
190 success: function (data, textStatus, jqXHR) {
191 processData(data);
192 },
193 error: function (jqXHR, textStatus, errorThrown) {
194 if (jqXHR.status === 200) {
195 processData(jqXHR.responseText);
196 } else {
197 var data = {};
198 data.responseDetails = 'Err...';
199 callback(data);
200 }
201 }
202 });
203},
167Transform.translate = function translate(v) {
168 var x = v[0] || 0;
169 var y = v[1] || 0;
170 var z = v[2] || 0;
171 return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, z, 1];
172};
38function translate(key, options) {
39
40 var lng = options.lng;
41
42 if (!translations[lng]) {
43 translations[lng] = {};
44 }
45
46 if (!t) {
47 translations[lng][key] = key;
48 } else {
49 translations[lng][key] = t(key, options);
50 }
51
52}
107function translate (pos, trans) {
108 pos.x += trans.x;
109 pos.y += trans.y;
110 return pos;
111}

Related snippets