PluginProbe
Translate and Go multilingual – Automatic AI translation – wpLingua / 1.0.4
Translate and Go multilingual – Automatic AI translation – wpLingua v1.0.4
2.16.5 2.16.4 2.16.3 2.16.2 2.16.1 2.16.0 2.15.2 2.15.1 2.15.0 2.14.3 2.14.2 2.14.1 2.14.0 2.13.1 2.13.0 2.12.3 2.12.2 2.12.1 trunk 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.2.0 All 110 releases
wplingua / data.php

data.php in Translate and Go multilingual – Automatic AI translation – wpLingua 1.0.4, at data.php

602 lines 14.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // If this file is called directly, abort.
4 if ( ! defined( 'WPINC' ) ) {
5 die;
6 }
7
8
9 /**
10 * ------ Data : Parse and translate ------
11 */
12
13 /**
14 * Get JSON elements to translate
15 *
16 * @return array
17 */
18 function wplng_data_json_to_translate() {
19 return apply_filters(
20 'wplng_json_to_translate',
21 array(
22 // Plugin : WooCommerce
23 array( 'wc_add_to_cart_params', 'i18n_view_cart' ),
24 array( 'wc_country_select_params', 'i18n_select_state_text' ),
25 array( 'wc_country_select_params', 'i18n_no_matches' ),
26 array( 'wc_country_select_params', 'i18n_ajax_error' ),
27 array( 'wc_country_select_params', 'i18n_input_too_short_1' ),
28 array( 'wc_country_select_params', 'i18n_input_too_short_n' ),
29 array( 'wc_country_select_params', 'i18n_input_too_long_1' ),
30 array( 'wc_country_select_params', 'i18n_input_too_long_n' ),
31 array( 'wc_country_select_params', 'i18n_selection_too_long_1' ),
32 array( 'wc_country_select_params', 'i18n_selection_too_long_n' ),
33 array( 'wc_country_select_params', 'i18n_load_more' ),
34 array( 'wc_country_select_params', 'i18n_searching' ),
35 array( 'wc_address_i18n_params', 'i18n_required_text' ),
36 array( 'wc_address_i18n_params', 'i18n_optional_text' ),
37 // Plugin : YITH
38 array( 'yith_wcwl_l10n', 'labels', 'cookie_disabled' ),
39 // Plugin : Yoast SEO
40 array( '@graph', 0, 'description' ),
41 )
42 );
43 }
44
45
46 /**
47 * Get JSON to exclude from translation
48 *
49 * @return array
50 */
51 function wplng_data_excluded_json() {
52 return apply_filters(
53 'wplng_excluded_json',
54 array(
55 array( 'wc_country_select_params', 'countries' ),
56 )
57 );
58 }
59
60
61 /**
62 * Get selectors of excluded elements in visual editor
63 *
64 * @return array
65 */
66 function wplng_data_excluded_editor_link() {
67 return apply_filters(
68 'wplng_excluded_editor_link',
69 array(
70 'textarea',
71 'pre',
72 'option',
73 )
74 );
75 }
76
77
78 /**
79 * Get selectors of excluded elements
80 *
81 * @return array
82 */
83 function wplng_data_excluded_selector_default() {
84 return array(
85 'style',
86 'svg',
87 'canvas',
88 'address',
89 'iframe',
90 'code',
91 '#wpadminbar',
92 '.no-translate',
93 '.notranslate',
94 '.wplng-switcher',
95 'link[hreflang]',
96 );
97 }
98
99
100 /**
101 * Get selectors of excluded nodes text
102 *
103 * @return array
104 */
105 function wplng_data_excluded_node_text() {
106 return apply_filters(
107 'wplng_excluded_node_text',
108 array(
109 'style',
110 'svg',
111 'canvas',
112 'link',
113 'script',
114 'code',
115 )
116 );
117 }
118
119
120 /**
121 * Get attributes and selectors to translate
122 *
123 * @return array
124 */
125 function wplng_data_attr_text_to_translate() {
126 return apply_filters(
127 'wplng_attr_text_to_translate',
128 array(
129 array(
130 'attr' => 'alt',
131 'selector' => '[alt]',
132 ),
133 array(
134 'attr' => 'title',
135 'selector' => '[title]',
136 ),
137 array(
138 'attr' => 'placeholder',
139 'selector' => '[placeholder]',
140 ),
141 array(
142 'attr' => 'aria-label',
143 'selector' => '[aria-label]',
144 ),
145 array(
146 'attr' => 'value',
147 'selector' => 'input[type="submit"][value]',
148 ),
149 array(
150 'attr' => 'content',
151 'selector' => 'meta[property="og:title"]',
152 ),
153 array(
154 'attr' => 'content',
155 'selector' => 'meta[property="og:description"]',
156 ),
157 array(
158 'attr' => 'content',
159 'selector' => 'meta[property="og:site_name"]',
160 ),
161 array(
162 'attr' => 'content',
163 'selector' => 'meta[name="twitter:title"]',
164 ),
165 array(
166 'attr' => 'content',
167 'selector' => 'meta[name="twitter:label1"]',
168 ),
169 array(
170 'attr' => 'content',
171 'selector' => 'meta[name="twitter:data1"]',
172 ),
173 array(
174 'attr' => 'content',
175 'selector' => 'meta[name="twitter:label2"]',
176 ),
177 array(
178 'attr' => 'content',
179 'selector' => 'meta[name="twitter:data2"]',
180 ),
181 array(
182 'attr' => 'content',
183 'selector' => 'meta[name="dc.title"]',
184 ),
185 array(
186 'attr' => 'content',
187 'selector' => 'meta[name="description"]',
188 ),
189 array(
190 'attr' => 'content',
191 'selector' => 'meta[name="dc.description"]',
192 ),
193 )
194 );
195 }
196
197
198 /**
199 * Get attributes and selectors of URL to translate
200 *
201 * @return array
202 */
203 function wplng_data_attr_url_to_translate() {
204 return apply_filters(
205 'wplng_attr_url_to_translate',
206 array(
207 array(
208 'attr' => 'href',
209 'selector' => 'a[href]',
210 ),
211 array(
212 'attr' => 'action',
213 'selector' => 'form[action]',
214 ),
215 array(
216 'attr' => 'content',
217 'selector' => 'meta[property="og:url"]',
218 ),
219 array(
220 'attr' => 'href',
221 'selector' => 'link[rel="canonical"]',
222 ),
223 array(
224 'attr' => 'content',
225 'selector' => 'meta[name="dc.relation"]',
226 ),
227 )
228 );
229 }
230
231
232 /**
233 * GEt attributes and selector of elements where translate language ID
234 *
235 * @return array
236 */
237 function wplng_data_attr_lang_id_to_replace() {
238 return apply_filters(
239 'wplng_attr_lang_id_to_replace',
240 array(
241 array(
242 'attr' => 'lang',
243 'selector' => 'html',
244 ),
245 array(
246 'attr' => 'content',
247 'selector' => 'meta[property="og:locale"]',
248 ),
249 array(
250 'attr' => 'content',
251 'selector' => 'meta[name="dc.language"]',
252 ),
253 )
254 );
255 }
256
257
258 /**
259 * ------ Data : Switcher options ------
260 */
261
262 /**
263 * Get options for switcher insertion
264 *
265 * @return array
266 */
267 function wplng_data_switcher_valid_insert() {
268 return array(
269 'bottom-right' => __( 'Bottom right', 'wplingua' ),
270 'bottom-center' => __( 'Bottom center', 'wplingua' ),
271 'bottom-left' => __( 'Bottom left', 'wplingua' ),
272 'none' => __( 'None', 'wplingua' ),
273 );
274 }
275
276
277 /**
278 * Get options for switcher themes
279 *
280 * @return array
281 */
282 function wplng_data_switcher_valid_theme() {
283 return array(
284 'light-double-smooth' => __( 'Light - Double - Smooth', 'wplingua' ),
285 'light-double-square' => __( 'Light - Double - Square', 'wplingua' ),
286 'light-simple-smooth' => __( 'Light - Simple - Smooth', 'wplingua' ),
287 'light-simple-square' => __( 'Light - Simple - Square', 'wplingua' ),
288 'grey-double-smooth' => __( 'Grey - Double - Smooth', 'wplingua' ),
289 'grey-double-square' => __( 'Grey - Double - Square', 'wplingua' ),
290 'grey-simple-smooth' => __( 'Grey - Simple - Smooth', 'wplingua' ),
291 'grey-simple-square' => __( 'Grey - Simple - Square', 'wplingua' ),
292 'dark-double-smooth' => __( 'Dark - Double - Smooth', 'wplingua' ),
293 'dark-double-square' => __( 'Dark - Double - Square', 'wplingua' ),
294 'dark-simple-smooth' => __( 'Dark - Simple - Smooth', 'wplingua' ),
295 'dark-simple-square' => __( 'Dark - Simple - Square', 'wplingua' ),
296 'blurblack-double-smooth' => __( 'Blur Black - Double - Smooth', 'wplingua' ),
297 'blurblack-double-square' => __( 'Blur Black - Double - Square', 'wplingua' ),
298 'blurblack-simple-smooth' => __( 'Blur Black - Simple - Smooth', 'wplingua' ),
299 'blurblack-simple-square' => __( 'Blur Black - Simple - Square', 'wplingua' ),
300 'blurwhite-double-smooth' => __( 'Blur White - Double - Smooth', 'wplingua' ),
301 'blurwhite-double-square' => __( 'Blur White - Double - Square', 'wplingua' ),
302 'blurwhite-simple-smooth' => __( 'Blur White - Simple - Smooth', 'wplingua' ),
303 'blurwhite-simple-square' => __( 'Blur White - Simple - Square', 'wplingua' ),
304 );
305 }
306
307
308 /**
309 * Get options for switcher style
310 *
311 * @return array
312 */
313 function wplng_data_switcher_valid_style() {
314 return array(
315 'list' => __( 'Inline list', 'wplingua' ),
316 'block' => __( 'Block', 'wplingua' ),
317 'dropdown' => __( 'Dropdown', 'wplingua' ),
318 );
319 }
320
321
322 /**
323 * Get options for switcher name format
324 *
325 * @return array
326 */
327 function wplng_data_switcher_valid_name_format() {
328 return array(
329 'name' => __( 'Translated name', 'wplingua' ),
330 'original' => __( 'Original name', 'wplingua' ),
331 'id' => __( 'Language ID', 'wplingua' ),
332 'none' => __( 'No display', 'wplingua' ),
333 );
334 }
335
336
337 /**
338 * Get options for switcher flags style
339 *
340 * @return array
341 */
342 function wplng_data_switcher_valid_flags_style() {
343 return array(
344 'circle' => __( 'Circle', 'wplingua' ),
345 'rectangular' => __( 'Rectangular', 'wplingua' ),
346 'wave' => __( 'Wave', 'wplingua' ),
347 'none' => __( 'No display', 'wplingua' ),
348 );
349 }
350
351
352 /**
353 * ------ Data : Languages ------
354 */
355
356 /**
357 * Get all languages data
358 *
359 * @return array
360 */
361 function wplng_data_languages() {
362 return array(
363 array(
364 'name' => __( 'Chinese', 'wplingua' ),
365 'id' => 'zh',
366 'flag' => 'cn',
367 'flags' => array(
368 array(
369 'name' => __( 'China', 'wplingua' ),
370 'id' => 'cn',
371 'flag' => 'cn',
372 ),
373 array(
374 'name' => __( 'Hong Kong', 'wplingua' ),
375 'id' => 'hk',
376 'flag' => 'hk',
377 ),
378 ),
379 'name_translation' => array(
380 'en' => 'Chinese',
381 'fr' => 'Chinois',
382 'de' => 'Chinesisch',
383 'it' => 'Cinese',
384 'pt' => 'Chinês',
385 'es' => 'Chino',
386 'ja' => 'チャイニーズ',
387 'ru' => 'Китайский',
388 'zh' => '中文',
389 ),
390 ),
391 array(
392 'name' => __( 'English', 'wplingua' ),
393 'id' => 'en',
394 'flag' => 'gb',
395 'flags' => array(
396 array(
397 'name' => __( 'UK', 'wplingua' ),
398 'id' => 'gb',
399 'flag' => 'gb',
400 ),
401 array(
402 'name' => __( 'USA', 'wplingua' ),
403 'id' => 'us',
404 'flag' => 'us',
405 ),
406 ),
407 'name_translation' => array(
408 'en' => 'English',
409 'fr' => 'Anglais',
410 'de' => 'Englisch',
411 'it' => 'Inglese',
412 'pt' => 'Inglês',
413 'es' => 'Inglés',
414 'ja' => 'イングリッシュ',
415 'ru' => 'Английский',
416 'zh' => '英语',
417 ),
418 ),
419 array(
420 'name' => __( 'French', 'wplingua' ),
421 'id' => 'fr',
422 'flag' => 'fr',
423 'flags' => array(
424 array(
425 'name' => __( 'France', 'wplingua' ),
426 'id' => 'fr',
427 'flag' => 'fr',
428 ),
429 array(
430 'name' => __( 'Belgium', 'wplingua' ),
431 'id' => 'be',
432 'flag' => 'be',
433 ),
434 array(
435 'name' => __( 'Canada', 'wplingua' ),
436 'id' => 'ca',
437 'flag' => 'ca',
438 ),
439 ),
440 'name_translation' => array(
441 'en' => 'French',
442 'fr' => 'Français',
443 'de' => 'Französisch',
444 'it' => 'Francese',
445 'pt' => 'Francês',
446 'es' => 'Francés',
447 'ja' => 'フレンチ',
448 'ru' => 'Французский',
449 'zh' => '法语',
450 ),
451 ),
452 array(
453 'name' => __( 'German', 'wplingua' ),
454 'id' => 'de',
455 'flag' => 'de',
456 'flags' => array(
457 array(
458 'name' => __( 'Germany', 'wplingua' ),
459 'id' => 'de',
460 'flag' => 'de',
461 ),
462 ),
463 'name_translation' => array(
464 'en' => 'German',
465 'fr' => 'Allemand',
466 'de' => 'Deutsch',
467 'it' => 'Tedesco',
468 'pt' => 'Alemão',
469 'es' => 'Alemán',
470 'ja' => 'ドイツ',
471 'ru' => 'Немецкий',
472 'zh' => '德国',
473 ),
474 ),
475 array(
476 'name' => __( 'Italian', 'wplingua' ),
477 'id' => 'it',
478 'flag' => 'it',
479 'flags' => array(
480 array(
481 'name' => __( 'Italy', 'wplingua' ),
482 'id' => 'it',
483 'flag' => 'it',
484 ),
485 ),
486 'name_translation' => array(
487 'en' => 'Italian',
488 'fr' => 'Italien',
489 'de' => 'Italienisch',
490 'it' => 'Italiano',
491 'pt' => 'Italiano',
492 'es' => 'Italiano',
493 'ja' => 'イタリア',
494 'ru' => 'Итальянский',
495 'zh' => '意大利',
496 ),
497 ),
498 array(
499 'name' => __( 'Japanese', 'wplingua' ),
500 'id' => 'ja',
501 'flag' => 'jp',
502 'flags' => array(
503 array(
504 'name' => __( 'Japan', 'wplingua' ),
505 'id' => 'jp',
506 'flag' => 'jp',
507 ),
508 ),
509 'name_translation' => array(
510 'en' => 'Japanese',
511 'fr' => 'Japonais',
512 'de' => 'Japanisch',
513 'it' => 'Giapponese',
514 'pt' => 'Japonês',
515 'es' => 'Japonés',
516 'ja' => '日本',
517 'ru' => 'Японский',
518 'zh' => '日语',
519 ),
520 ),
521 array(
522 'name' => __( 'Portuguese', 'wplingua' ),
523 'id' => 'pt',
524 'flag' => 'pt',
525 'flags' => array(
526 array(
527 'name' => __( 'Portugal', 'wplingua' ),
528 'id' => 'pt',
529 'flag' => 'pt',
530 ),
531 array(
532 'name' => __( 'Brazil', 'wplingua' ),
533 'id' => 'br',
534 'flag' => 'br',
535 ),
536 ),
537 'name_translation' => array(
538 'en' => 'Portuguese',
539 'fr' => 'Portugais',
540 'de' => 'Portugiesisch',
541 'it' => 'Portoghese',
542 'pt' => 'Português',
543 'es' => 'Portugués',
544 'ja' => 'ポルトガル',
545 'ru' => 'Португальский',
546 'zh' => '葡语',
547 ),
548 ),
549 array(
550 'name' => __( 'Russian', 'wplingua' ),
551 'id' => 'ru',
552 'flag' => 'ru',
553 'flags' => array(
554 array(
555 'name' => __( 'Russia', 'wplingua' ),
556 'id' => 'ru',
557 'flag' => 'ru',
558 ),
559 ),
560 'name_translation' => array(
561 'en' => 'Russian',
562 'fr' => 'Russe',
563 'de' => 'Russisch',
564 'it' => 'Russo',
565 'pt' => 'Russo',
566 'es' => 'Ruso',
567 'ja' => 'ロシア',
568 'ru' => 'Японский',
569 'zh' => '日语',
570 ),
571 ),
572 array(
573 'name' => __( 'Spanish', 'wplingua' ),
574 'id' => 'es',
575 'flag' => 'es',
576 'flags' => array(
577 array(
578 'name' => __( 'Spain', 'wplingua' ),
579 'id' => 'es',
580 'flag' => 'es',
581 ),
582 array(
583 'name' => __( 'Mexico', 'wplingua' ),
584 'id' => 'mx',
585 'flag' => 'mx',
586 ),
587 ),
588 'name_translation' => array(
589 'en' => 'Spanish',
590 'fr' => 'Espagnol',
591 'de' => 'Spanisch',
592 'it' => 'Spagnolo',
593 'pt' => 'Espanhol',
594 'es' => 'Español',
595 'ja' => 'スペイン',
596 'ru' => 'Испанский',
597 'zh' => '英语',
598 ),
599 ),
600 );
601 }
602