| 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:description"]', |
| 168 |
), |
| 169 |
array( |
| 170 |
'attr' => 'content', |
| 171 |
'selector' => 'meta[name="twitter:label1"]', |
| 172 |
), |
| 173 |
array( |
| 174 |
'attr' => 'content', |
| 175 |
'selector' => 'meta[name="twitter:data1"]', |
| 176 |
), |
| 177 |
array( |
| 178 |
'attr' => 'content', |
| 179 |
'selector' => 'meta[name="twitter:label2"]', |
| 180 |
), |
| 181 |
array( |
| 182 |
'attr' => 'content', |
| 183 |
'selector' => 'meta[name="twitter:data2"]', |
| 184 |
), |
| 185 |
array( |
| 186 |
'attr' => 'content', |
| 187 |
'selector' => 'meta[name="dc.title"]', |
| 188 |
), |
| 189 |
array( |
| 190 |
'attr' => 'content', |
| 191 |
'selector' => 'meta[name="description"]', |
| 192 |
), |
| 193 |
array( |
| 194 |
'attr' => 'content', |
| 195 |
'selector' => 'meta[name="dc.description"]', |
| 196 |
), |
| 197 |
) |
| 198 |
); |
| 199 |
} |
| 200 |
|
| 201 |
|
| 202 |
/** |
| 203 |
* Get attributes and selectors of URL to translate |
| 204 |
* |
| 205 |
* @return array |
| 206 |
*/ |
| 207 |
function wplng_data_attr_url_to_translate() { |
| 208 |
return apply_filters( |
| 209 |
'wplng_attr_url_to_translate', |
| 210 |
array( |
| 211 |
array( |
| 212 |
'attr' => 'href', |
| 213 |
'selector' => 'a[href]', |
| 214 |
), |
| 215 |
array( |
| 216 |
'attr' => 'action', |
| 217 |
'selector' => 'form[action]', |
| 218 |
), |
| 219 |
array( |
| 220 |
'attr' => 'content', |
| 221 |
'selector' => 'meta[property="og:url"]', |
| 222 |
), |
| 223 |
array( |
| 224 |
'attr' => 'href', |
| 225 |
'selector' => 'link[rel="canonical"]', |
| 226 |
), |
| 227 |
array( |
| 228 |
'attr' => 'content', |
| 229 |
'selector' => 'meta[name="dc.relation"]', |
| 230 |
), |
| 231 |
) |
| 232 |
); |
| 233 |
} |
| 234 |
|
| 235 |
|
| 236 |
/** |
| 237 |
* GEt attributes and selector of elements where translate language ID |
| 238 |
* |
| 239 |
* @return array |
| 240 |
*/ |
| 241 |
function wplng_data_attr_lang_id_to_replace() { |
| 242 |
return apply_filters( |
| 243 |
'wplng_attr_lang_id_to_replace', |
| 244 |
array( |
| 245 |
array( |
| 246 |
'attr' => 'lang', |
| 247 |
'selector' => 'html', |
| 248 |
), |
| 249 |
array( |
| 250 |
'attr' => 'content', |
| 251 |
'selector' => 'meta[property="og:locale"]', |
| 252 |
), |
| 253 |
array( |
| 254 |
'attr' => 'content', |
| 255 |
'selector' => 'meta[name="dc.language"]', |
| 256 |
), |
| 257 |
) |
| 258 |
); |
| 259 |
} |
| 260 |
|
| 261 |
|
| 262 |
/** |
| 263 |
* ------ Data : Switcher options ------ |
| 264 |
*/ |
| 265 |
|
| 266 |
/** |
| 267 |
* Get options for switcher insertion |
| 268 |
* |
| 269 |
* @return array |
| 270 |
*/ |
| 271 |
function wplng_data_switcher_valid_insert() { |
| 272 |
return array( |
| 273 |
'bottom-right' => __( 'Bottom right', 'wplingua' ), |
| 274 |
'bottom-center' => __( 'Bottom center', 'wplingua' ), |
| 275 |
'bottom-left' => __( 'Bottom left', 'wplingua' ), |
| 276 |
'none' => __( 'None', 'wplingua' ), |
| 277 |
); |
| 278 |
} |
| 279 |
|
| 280 |
|
| 281 |
/** |
| 282 |
* Get options for switcher themes |
| 283 |
* |
| 284 |
* @return array |
| 285 |
*/ |
| 286 |
function wplng_data_switcher_valid_theme() { |
| 287 |
return array( |
| 288 |
'light-double-smooth' => __( 'Light - Double - Smooth', 'wplingua' ), |
| 289 |
'light-double-square' => __( 'Light - Double - Square', 'wplingua' ), |
| 290 |
'light-simple-smooth' => __( 'Light - Simple - Smooth', 'wplingua' ), |
| 291 |
'light-simple-square' => __( 'Light - Simple - Square', 'wplingua' ), |
| 292 |
'grey-double-smooth' => __( 'Grey - Double - Smooth', 'wplingua' ), |
| 293 |
'grey-double-square' => __( 'Grey - Double - Square', 'wplingua' ), |
| 294 |
'grey-simple-smooth' => __( 'Grey - Simple - Smooth', 'wplingua' ), |
| 295 |
'grey-simple-square' => __( 'Grey - Simple - Square', 'wplingua' ), |
| 296 |
'dark-double-smooth' => __( 'Dark - Double - Smooth', 'wplingua' ), |
| 297 |
'dark-double-square' => __( 'Dark - Double - Square', 'wplingua' ), |
| 298 |
'dark-simple-smooth' => __( 'Dark - Simple - Smooth', 'wplingua' ), |
| 299 |
'dark-simple-square' => __( 'Dark - Simple - Square', 'wplingua' ), |
| 300 |
'blurblack-double-smooth' => __( 'Blur Black - Double - Smooth', 'wplingua' ), |
| 301 |
'blurblack-double-square' => __( 'Blur Black - Double - Square', 'wplingua' ), |
| 302 |
'blurblack-simple-smooth' => __( 'Blur Black - Simple - Smooth', 'wplingua' ), |
| 303 |
'blurblack-simple-square' => __( 'Blur Black - Simple - Square', 'wplingua' ), |
| 304 |
'blurwhite-double-smooth' => __( 'Blur White - Double - Smooth', 'wplingua' ), |
| 305 |
'blurwhite-double-square' => __( 'Blur White - Double - Square', 'wplingua' ), |
| 306 |
'blurwhite-simple-smooth' => __( 'Blur White - Simple - Smooth', 'wplingua' ), |
| 307 |
'blurwhite-simple-square' => __( 'Blur White - Simple - Square', 'wplingua' ), |
| 308 |
); |
| 309 |
} |
| 310 |
|
| 311 |
|
| 312 |
/** |
| 313 |
* Get options for switcher style |
| 314 |
* |
| 315 |
* @return array |
| 316 |
*/ |
| 317 |
function wplng_data_switcher_valid_style() { |
| 318 |
return array( |
| 319 |
'list' => __( 'Inline list', 'wplingua' ), |
| 320 |
'block' => __( 'Block', 'wplingua' ), |
| 321 |
'dropdown' => __( 'Dropdown', 'wplingua' ), |
| 322 |
); |
| 323 |
} |
| 324 |
|
| 325 |
|
| 326 |
/** |
| 327 |
* Get options for switcher name format |
| 328 |
* |
| 329 |
* @return array |
| 330 |
*/ |
| 331 |
function wplng_data_switcher_valid_name_format() { |
| 332 |
return array( |
| 333 |
'name' => __( 'Translated name', 'wplingua' ), |
| 334 |
'original' => __( 'Original name', 'wplingua' ), |
| 335 |
'id' => __( 'Language ID', 'wplingua' ), |
| 336 |
'none' => __( 'No display', 'wplingua' ), |
| 337 |
); |
| 338 |
} |
| 339 |
|
| 340 |
|
| 341 |
/** |
| 342 |
* Get options for switcher flags style |
| 343 |
* |
| 344 |
* @return array |
| 345 |
*/ |
| 346 |
function wplng_data_switcher_valid_flags_style() { |
| 347 |
return array( |
| 348 |
'circle' => __( 'Circle', 'wplingua' ), |
| 349 |
'rectangular' => __( 'Rectangular', 'wplingua' ), |
| 350 |
'wave' => __( 'Wave', 'wplingua' ), |
| 351 |
'none' => __( 'No display', 'wplingua' ), |
| 352 |
); |
| 353 |
} |
| 354 |
|
| 355 |
|
| 356 |
/** |
| 357 |
* ------ Data : Languages ------ |
| 358 |
*/ |
| 359 |
|
| 360 |
/** |
| 361 |
* Get all languages data |
| 362 |
* |
| 363 |
* @return array |
| 364 |
*/ |
| 365 |
function wplng_data_languages() { |
| 366 |
return array( |
| 367 |
array( |
| 368 |
'name' => __( 'Chinese', 'wplingua' ), |
| 369 |
'id' => 'zh', |
| 370 |
'flag' => 'cn', |
| 371 |
'flags' => array( |
| 372 |
array( |
| 373 |
'name' => __( 'China', 'wplingua' ), |
| 374 |
'id' => 'cn', |
| 375 |
'flag' => 'cn', |
| 376 |
), |
| 377 |
array( |
| 378 |
'name' => __( 'Hong Kong', 'wplingua' ), |
| 379 |
'id' => 'hk', |
| 380 |
'flag' => 'hk', |
| 381 |
), |
| 382 |
), |
| 383 |
'name_translation' => array( |
| 384 |
'en' => 'Chinese', |
| 385 |
'fr' => 'Chinois', |
| 386 |
'de' => 'Chinesisch', |
| 387 |
'it' => 'Cinese', |
| 388 |
'pt' => 'Chinês', |
| 389 |
'es' => 'Chino', |
| 390 |
'ja' => 'チャイニーズ', |
| 391 |
'ru' => 'Китайский', |
| 392 |
'zh' => '中文', |
| 393 |
), |
| 394 |
), |
| 395 |
array( |
| 396 |
'name' => __( 'English', 'wplingua' ), |
| 397 |
'id' => 'en', |
| 398 |
'flag' => 'gb', |
| 399 |
'flags' => array( |
| 400 |
array( |
| 401 |
'name' => __( 'UK', 'wplingua' ), |
| 402 |
'id' => 'gb', |
| 403 |
'flag' => 'gb', |
| 404 |
), |
| 405 |
array( |
| 406 |
'name' => __( 'USA', 'wplingua' ), |
| 407 |
'id' => 'us', |
| 408 |
'flag' => 'us', |
| 409 |
), |
| 410 |
), |
| 411 |
'name_translation' => array( |
| 412 |
'en' => 'English', |
| 413 |
'fr' => 'Anglais', |
| 414 |
'de' => 'Englisch', |
| 415 |
'it' => 'Inglese', |
| 416 |
'pt' => 'Inglês', |
| 417 |
'es' => 'Inglés', |
| 418 |
'ja' => 'イングリッシュ', |
| 419 |
'ru' => 'Английский', |
| 420 |
'zh' => '英语', |
| 421 |
), |
| 422 |
), |
| 423 |
array( |
| 424 |
'name' => __( 'French', 'wplingua' ), |
| 425 |
'id' => 'fr', |
| 426 |
'flag' => 'fr', |
| 427 |
'flags' => array( |
| 428 |
array( |
| 429 |
'name' => __( 'France', 'wplingua' ), |
| 430 |
'id' => 'fr', |
| 431 |
'flag' => 'fr', |
| 432 |
), |
| 433 |
array( |
| 434 |
'name' => __( 'Belgium', 'wplingua' ), |
| 435 |
'id' => 'be', |
| 436 |
'flag' => 'be', |
| 437 |
), |
| 438 |
array( |
| 439 |
'name' => __( 'Canada', 'wplingua' ), |
| 440 |
'id' => 'ca', |
| 441 |
'flag' => 'ca', |
| 442 |
), |
| 443 |
), |
| 444 |
'name_translation' => array( |
| 445 |
'en' => 'French', |
| 446 |
'fr' => 'Français', |
| 447 |
'de' => 'Französisch', |
| 448 |
'it' => 'Francese', |
| 449 |
'pt' => 'Francês', |
| 450 |
'es' => 'Francés', |
| 451 |
'ja' => 'フレンチ', |
| 452 |
'ru' => 'Французский', |
| 453 |
'zh' => '法语', |
| 454 |
), |
| 455 |
), |
| 456 |
array( |
| 457 |
'name' => __( 'German', 'wplingua' ), |
| 458 |
'id' => 'de', |
| 459 |
'flag' => 'de', |
| 460 |
'flags' => array( |
| 461 |
array( |
| 462 |
'name' => __( 'Germany', 'wplingua' ), |
| 463 |
'id' => 'de', |
| 464 |
'flag' => 'de', |
| 465 |
), |
| 466 |
), |
| 467 |
'name_translation' => array( |
| 468 |
'en' => 'German', |
| 469 |
'fr' => 'Allemand', |
| 470 |
'de' => 'Deutsch', |
| 471 |
'it' => 'Tedesco', |
| 472 |
'pt' => 'Alemão', |
| 473 |
'es' => 'Alemán', |
| 474 |
'ja' => 'ドイツ', |
| 475 |
'ru' => 'Немецкий', |
| 476 |
'zh' => '德国', |
| 477 |
), |
| 478 |
), |
| 479 |
array( |
| 480 |
'name' => __( 'Italian', 'wplingua' ), |
| 481 |
'id' => 'it', |
| 482 |
'flag' => 'it', |
| 483 |
'flags' => array( |
| 484 |
array( |
| 485 |
'name' => __( 'Italy', 'wplingua' ), |
| 486 |
'id' => 'it', |
| 487 |
'flag' => 'it', |
| 488 |
), |
| 489 |
), |
| 490 |
'name_translation' => array( |
| 491 |
'en' => 'Italian', |
| 492 |
'fr' => 'Italien', |
| 493 |
'de' => 'Italienisch', |
| 494 |
'it' => 'Italiano', |
| 495 |
'pt' => 'Italiano', |
| 496 |
'es' => 'Italiano', |
| 497 |
'ja' => 'イタリア', |
| 498 |
'ru' => 'Итальянский', |
| 499 |
'zh' => '意大利', |
| 500 |
), |
| 501 |
), |
| 502 |
array( |
| 503 |
'name' => __( 'Japanese', 'wplingua' ), |
| 504 |
'id' => 'ja', |
| 505 |
'flag' => 'jp', |
| 506 |
'flags' => array( |
| 507 |
array( |
| 508 |
'name' => __( 'Japan', 'wplingua' ), |
| 509 |
'id' => 'jp', |
| 510 |
'flag' => 'jp', |
| 511 |
), |
| 512 |
), |
| 513 |
'name_translation' => array( |
| 514 |
'en' => 'Japanese', |
| 515 |
'fr' => 'Japonais', |
| 516 |
'de' => 'Japanisch', |
| 517 |
'it' => 'Giapponese', |
| 518 |
'pt' => 'Japonês', |
| 519 |
'es' => 'Japonés', |
| 520 |
'ja' => '日本', |
| 521 |
'ru' => 'Японский', |
| 522 |
'zh' => '日语', |
| 523 |
), |
| 524 |
), |
| 525 |
array( |
| 526 |
'name' => __( 'Portuguese', 'wplingua' ), |
| 527 |
'id' => 'pt', |
| 528 |
'flag' => 'pt', |
| 529 |
'flags' => array( |
| 530 |
array( |
| 531 |
'name' => __( 'Portugal', 'wplingua' ), |
| 532 |
'id' => 'pt', |
| 533 |
'flag' => 'pt', |
| 534 |
), |
| 535 |
array( |
| 536 |
'name' => __( 'Brazil', 'wplingua' ), |
| 537 |
'id' => 'br', |
| 538 |
'flag' => 'br', |
| 539 |
), |
| 540 |
), |
| 541 |
'name_translation' => array( |
| 542 |
'en' => 'Portuguese', |
| 543 |
'fr' => 'Portugais', |
| 544 |
'de' => 'Portugiesisch', |
| 545 |
'it' => 'Portoghese', |
| 546 |
'pt' => 'Português', |
| 547 |
'es' => 'Portugués', |
| 548 |
'ja' => 'ポルトガル', |
| 549 |
'ru' => 'Португальский', |
| 550 |
'zh' => '葡语', |
| 551 |
), |
| 552 |
), |
| 553 |
array( |
| 554 |
'name' => __( 'Russian', 'wplingua' ), |
| 555 |
'id' => 'ru', |
| 556 |
'flag' => 'ru', |
| 557 |
'flags' => array( |
| 558 |
array( |
| 559 |
'name' => __( 'Russia', 'wplingua' ), |
| 560 |
'id' => 'ru', |
| 561 |
'flag' => 'ru', |
| 562 |
), |
| 563 |
), |
| 564 |
'name_translation' => array( |
| 565 |
'en' => 'Russian', |
| 566 |
'fr' => 'Russe', |
| 567 |
'de' => 'Russisch', |
| 568 |
'it' => 'Russo', |
| 569 |
'pt' => 'Russo', |
| 570 |
'es' => 'Ruso', |
| 571 |
'ja' => 'ロシア', |
| 572 |
'ru' => 'Японский', |
| 573 |
'zh' => '日语', |
| 574 |
), |
| 575 |
), |
| 576 |
array( |
| 577 |
'name' => __( 'Spanish', 'wplingua' ), |
| 578 |
'id' => 'es', |
| 579 |
'flag' => 'es', |
| 580 |
'flags' => array( |
| 581 |
array( |
| 582 |
'name' => __( 'Spain', 'wplingua' ), |
| 583 |
'id' => 'es', |
| 584 |
'flag' => 'es', |
| 585 |
), |
| 586 |
array( |
| 587 |
'name' => __( 'Mexico', 'wplingua' ), |
| 588 |
'id' => 'mx', |
| 589 |
'flag' => 'mx', |
| 590 |
), |
| 591 |
), |
| 592 |
'name_translation' => array( |
| 593 |
'en' => 'Spanish', |
| 594 |
'fr' => 'Espagnol', |
| 595 |
'de' => 'Spanisch', |
| 596 |
'it' => 'Spagnolo', |
| 597 |
'pt' => 'Espanhol', |
| 598 |
'es' => 'Español', |
| 599 |
'ja' => 'スペイン', |
| 600 |
'ru' => 'Испанский', |
| 601 |
'zh' => '英语', |
| 602 |
), |
| 603 |
), |
| 604 |
); |
| 605 |
} |
| 606 |
|