Changeset 3468722
- Timestamp:
- 02/24/2026 03:07:11 PM (5 weeks ago)
- Location:
- conveythis-translate/trunk
- Files:
-
- 7 edited
-
app/class/ConveyThis.php (modified) (9 diffs)
-
app/class/Variables.php (modified) (1 diff)
-
app/widget/js/settings.js (modified) (1 diff)
-
changelog.txt (modified) (1 diff)
-
config.php (modified) (1 diff)
-
index.php (modified) (1 diff)
-
readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
conveythis-translate/trunk/app/class/ConveyThis.php
r3465205 r3468722 10 10 private $nodePathList = []; 11 11 private $nodePathListSpace = []; 12 private $templateVarMap = []; 12 13 13 14 function __construct() { 15 if (!isset($_SERVER['HTTP_HOST'])) { 16 $_SERVER['HTTP_HOST'] = parse_url(home_url(), PHP_URL_HOST) ?: ''; 17 } 18 if (!isset($_SERVER['REQUEST_URI'])) { 19 $_SERVER['REQUEST_URI'] = '/'; 20 } 21 if (!isset($_SERVER['REQUEST_SCHEME'])) { 22 $_SERVER['REQUEST_SCHEME'] = is_ssl() ? 'https' : 'http'; 23 } 24 14 25 $this->print_log('__construct()'); 15 26 $this->print_log("***********************"); … … 2480 2491 $doc->formatOutput = true; 2481 2492 libxml_use_internal_errors(true); 2482 if (extension_loaded('mbstring')) { 2483 $doc->loadHTML(mb_convert_encoding($output, 'HTML-ENTITIES', 'UTF-8')); 2493 2494 // Inject UTF-8 charset declaration so DOMDocument interprets the 2495 // document correctly. Replaces deprecated mb_convert_encoding(). 2496 // Compatible with PHP 7.x and PHP 8.x. 2497 if (stripos($output, '<head') !== false) { 2498 $output = preg_replace( 2499 '/<head(\s[^>]*)?>/i', 2500 '<head$1><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">', 2501 $output, 2502 1 2503 ); 2484 2504 } else { 2485 $doc->loadHTML($output); 2486 } 2505 $output = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body>' . $output . '</body></html>'; 2506 } 2507 2508 $doc->loadHTML($output); 2487 2509 libxml_clear_errors(); 2488 2510 return $doc; … … 2492 2514 $this->print_log("* searchSegment()"); 2493 2515 $source_text = html_entity_decode($value); 2516 $source_text = $this->protectTemplateVars($source_text); 2494 2517 $source_text = trim(preg_replace("/\<!--(.*?)\-->/", "", $source_text)); 2495 2518 … … 2502 2525 $source_text2 = isset($item['source_text']) ? html_entity_decode($item['source_text']) : ''; 2503 2526 if (strcmp($source_text, trim($source_text2)) === 0) { 2504 return str_replace($source_text, $item['translate_text'], $source_text);2527 return $this->restoreTemplateVars(str_replace($source_text, $item['translate_text'], $source_text)); 2505 2528 } 2506 2529 } … … 2523 2546 2524 2547 if (strcmp($source_text, trim($source2Lower)) === 0) { 2525 return str_replace($source_text, $item['translate_text'], $source_text);2548 return $this->restoreTemplateVars(str_replace($source_text, $item['translate_text'], $source_text)); 2526 2549 } 2527 2550 } … … 2536 2559 2537 2560 if (strcmp($source_text, wp_strip_all_tags($source2Lower)) === 0) { 2538 return str_replace($source_text, $item['translate_text'], $source_text);2561 return $this->restoreTemplateVars(str_replace($source_text, $item['translate_text'], $source_text)); 2539 2562 } 2540 2563 } … … 2788 2811 $content = html_entity_decode($content, ENT_HTML5, 'UTF-8'); 2789 2812 2813 // Remove C1 control characters (U+0080–U+009F) that are never valid in 2814 // HTML or JavaScript and can cause SyntaxError in browsers. 2815 // Compatible with PHP 7.x and PHP 8.x. 2816 $cleaned = preg_replace('/[\x{0080}-\x{009F}]/u', '', $content); 2817 if ($cleaned !== null) { 2818 $content = $cleaned; 2819 } 2820 2790 2821 //$this->print_log("############ content: #############"); 2791 2822 // $this->print_log($content); … … 2821 2852 foreach ($segments as $segment) { 2822 2853 if (preg_match('/\p{L}/u', $segment)) { 2823 $res[] = $segment; 2854 // Skip segments that consist entirely of template variables 2855 $stripped = preg_replace('/\{\{\{?.+?\}?\}\}/', '', $segment); 2856 if (trim($stripped) === '') { 2857 continue; 2858 } 2859 $res[] = $this->protectTemplateVars($segment); 2824 2860 } 2825 2861 } 2826 2862 } 2827 2863 return $res; 2864 } 2865 2866 /** 2867 * Replace {{ ... }} and {{{ ... }}} template expressions with deterministic 2868 * placeholders so they are not sent for translation. 2869 * Compatible with PHP 7.x and PHP 8.x. 2870 */ 2871 private function protectTemplateVars($text) { 2872 return preg_replace_callback('/\{\{\{?.+?\}?\}\}/', function ($matches) { 2873 $original = $matches[0]; 2874 $placeholder = 'CTXNTP_' . substr(md5($original), 0, 10); 2875 $this->templateVarMap[$placeholder] = $original; 2876 return $placeholder; 2877 }, $text); 2878 } 2879 2880 /** 2881 * Restore template-variable placeholders back to their original {{ ... }} form. 2882 */ 2883 private function restoreTemplateVars($text) { 2884 if (!empty($this->templateVarMap)) { 2885 $text = str_replace( 2886 array_keys($this->templateVarMap), 2887 array_values($this->templateVarMap), 2888 $text 2889 ); 2890 } 2891 return $text; 2828 2892 } 2829 2893 … … 2928 2992 $val_trimmed = trim($val); 2929 2993 $val_trimmed = html_entity_decode($val_trimmed, ENT_QUOTES | ENT_HTML5, 'UTF-8'); 2930 if (isset($translations[$val_trimmed])) { 2994 $val_protected = $this->protectTemplateVars($val_trimmed); 2995 if (isset($translations[$val_protected])) { 2996 $val = $this->restoreTemplateVars($translations[$val_protected]); 2997 } elseif (isset($translations[$val_trimmed])) { 2931 2998 $val = $translations[$val_trimmed]; 2932 2999 } -
conveythis-translate/trunk/app/class/Variables.php
r3460968 r3468722 589 589 908 => array('language_id' => 908, 'title_en' => 'Upper Sorbian', 'title' => 'Hornjoserbšćina', 'code2' => 'hsb', 'code3' => 'hsb', 'flag' => 'de'), 590 590 909 => array('language_id' => 909, 'title_en' => 'Yucatec Maya', 'title' => 'Maya tʼàan', 'code2' => 'yua', 'code3' => 'yua', 'flag' => 'mx'), 591 592 // New Languages 593 910 => array('language_id' => 910, 'title_en' => 'Arabic (Egypt)', 'title' => 'Arabic (Egypt)', 'code2' => 'ar-eg', 'code3' => 'ara', 'flag' => 'eg'), 594 911 => array('language_id' => 911, 'title_en' => 'Arabic (UAE)', 'title' => 'Arabic (UAE)', 'code2' => 'ar-ae', 'code3' => 'ara', 'flag' => 'ae'), 595 912 => array('language_id' => 912, 'title_en' => 'English (UK)', 'title' => 'English (UK)', 'code2' => 'en-gb', 'code3' => 'eng', 'flag' => 'gb'), 596 913 => array('language_id' => 913, 'title_en' => 'English (Australia)', 'title' => 'English (Australia)', 'code2' => 'en-au', 'code3' => 'eng', 'flag' => 'au'), 597 914 => array('language_id' => 914, 'title_en' => 'Spanish (Mexico)', 'title' => 'Spanish (Mexico)', 'code2' => 'es-mx', 'code3' => 'spa', 'flag' => 'mx'), 598 915 => array('language_id' => 915, 'title_en' => 'Spanish (US)', 'title' => 'Spanish (US)', 'code2' => 'es-us', 'code3' => 'spa', 'flag' => 'us'), 599 916 => array('language_id' => 916, 'title_en' => 'French (Canada)', 'title' => 'French (Canada)', 'code2' => 'fr-ca', 'code3' => 'fre', 'flag' => 'ca'), 591 600 ); 592 601 -
conveythis-translate/trunk/app/widget/js/settings.js
r3460968 r3468722 680 680 907: {'title_en': 'Twi', 'title': 'Twi', 'code2': 'ak', 'code3': 'aka', 'flag': '6Mr'}, 681 681 908: {'title_en': 'Upper Sorbian', 'title': 'Upper Sorbian', 'code2': 'hsb', 'code3': 'hsb', 'flag': 'K7e'}, 682 909: {'title_en': 'Yucatec Maya', 'title': 'Yucatec Maya', 'code2': 'yua', 'code3': 'yua', 'flag': '8Qb'} 682 909: {'title_en': 'Yucatec Maya', 'title': 'Yucatec Maya', 'code2': 'yua', 'code3': 'yua', 'flag': '8Qb'}, 683 684 // New Languages 685 910: {'title_en': 'Arabic (Egypt)', 'title': 'Arabic (Egypt)', 'code2': 'ar-eg', 'code3': 'ara', 'flag': 'eg'}, 686 911: {'title_en': 'Arabic (UAE)', 'title': 'Arabic (UAE)', 'code2': 'ar-ae', 'code3': 'ara', 'flag': 'ae'}, 687 912: {'title_en': 'English (UK)', 'title': 'English (UK)', 'code2': 'en-gb', 'code3': 'eng', 'flag': 'gb'}, 688 913: {'title_en': 'English (Australia)', 'title': 'English (Australia)', 'code2': 'en-au', 'code3': 'eng', 'flag': 'au'}, 689 914: {'title_en': 'Spanish (Mexico)', 'title': 'Spanish (Mexico)', 'code2': 'es-mx', 'code3': 'spa', 'flag': 'mx'}, 690 915: {'title_en': 'Spanish (USA)', 'title': 'Spanish (USA)', 'code2': 'es-us', 'code3': 'spa', 'flag': 'us'}, 691 916: {'title_en': 'French (Canada)', 'title': 'French (Canada)', 'code2': 'fr-ca', 'code3': 'fre', 'flag': 'ca'}, 683 692 } 684 693 -
conveythis-translate/trunk/changelog.txt
r3465205 r3468722 1 1 == Changelog == 2 = 269.6 = 3 * Dialects + fixes added 4 2 5 = 269.5 = 3 6 * Instructions for Exclusion pages added -
conveythis-translate/trunk/config.php
r3465205 r3468722 61 61 62 62 define('CONVEYTHIS_LOADER', true); 63 define('CONVEYTHIS_PLUGIN_VERSION', '269. 5');63 define('CONVEYTHIS_PLUGIN_VERSION', '269.6'); 64 64 define('CONVEY_PLUGIN_ROOT_PATH', plugin_dir_path( __FILE__ )); 65 65 define('CONVEY_PLUGIN_PATH', plugin_dir_url(__FILE__)); -
conveythis-translate/trunk/index.php
r3465205 r3468722 4 4 Plugin URI: https://www.conveythis.com/?utm_source=widget&utm_medium=wordpress 5 5 Description: Translate your WordPress site into over 100 languages using professional and instant machine translation technology. ConveyThis will help provide you with an SEO-friendy, multilingual website in minutes with no coding required. 6 Version: 269. 56 Version: 269.6 7 7 8 8 Author: ConveyThis Translate Team -
conveythis-translate/trunk/readme.txt
r3465205 r3468722 6 6 Tested up to: 6.9.1 7 7 8 Stable tag: 269. 58 Stable tag: 269.6 9 9 10 10 License: GPLv2 … … 107 107 **Popular languages:** English, Spanish, French, German, Chinese, Japanese, Korean, Arabic, Portuguese, Russian, Italian, Dutch, Ukrainian 108 108 109 **Additional languages:** Abkhaz, Acehnese, Acholi, Afrikaans, Albanian, Alur, Amharic, Armenian, Assamese, Awadhi, Aymara, Azerbaijani, Balinese, Bambara, Bashkir, Basque, Batak Karo, Batak Simalungun, Batak Toba, Belarusian, Bemba, Bengali, Betawi, Bhojpuri, Bikol, Bodo, Bosnian, Breton, Bulgarian, Burmese, Buryat, Cantonese, Catalan, Cebuano, Chhattisgarhi, Chichewa, Chinese (Simpl .), Chinese (Trad.), Chuvash, Corsican, Crimean Tatar, Croatian, Czech, Danish, Dari, Dinka, Divehi, Dogri, Dombe, Dzongkha, Esperanto, Estonian, Ewe, Faroese, Fijian, Finnish, Frisian, Fulfulde, Ga, Galician, Ganda, Georgian, Greek, Guarani, Gujarati, Haitian (Creole), Hakha Chin, Hausa, Hawaiian, Hebrew, Hiligaynon, Hindi, Hmong, Hungarian, Hunsrik, Icelandic, Igbo, Iloko, Indonesian, Inuinnaqtun, Inuktitut, Irish, Javanese, Kannada, Kapampangan, Kashmiri, Kazakh, Khmer, Kiga, Kinyarwanda, Kituba, Konkani, Krio, Kurdish (Central), Kyrgyz, Laotian, Latgalian, Latin, Latvian, Ligurian, Limburgan, Lingala, Lithuanian, Lombard, Lower Sorbian, Luo, Luxembourgish, Macedonian, Maithili, Makassar, Malagasy, Malay, Malayalam, Maltese, Manipuri, Maori, Marathi, Meadow Mari, Minang, Mizo, Mongolian, Ndebele (South), Nepalbhasa, Nepali, Northern Sotho, Norwegian, Nuer, Occitan, Odia, Oromo, Pangasinan, Papiamento, Pashto, Persian, Polish, Portuguese (BR), Portuguese (PT), Punjabi, Quechua, Queretaro Otomi, Romani, Romanian, Rundi, Samoan, Sango, Sanskrit, Scottish, Serbian, Sesotho, Seychellois Creole, Shan, Shona, Sicilian, Silesian, Sindhi, Sinhala, Slovakian, Slovenian, Somali, Sundanese, Swahili, Swati, Swedish, Tagalog, Tahitian, Tajik, Tamil, Tatar, Telugu, Tetum, Thai, Tibetan, Tigrinya, Tongan, Tsonga, Tswana, Turkish, Turkmen, Twi, Upper Sorbian, Urdu, Uyghur, Uzbek, Vietnamese, Welsh, Xhosa, Yiddish, Yoruba, Yucatec Maya, Zulu110 111 **Custom languages & dialects:** C reate your own language variations using **templates** (e.g., British English, Canadian French) or start from scratch.109 **Additional languages:** Abkhaz, Acehnese, Acholi, Afrikaans, Albanian, Alur, Amharic, Armenian, Assamese, Awadhi, Aymara, Azerbaijani, Balinese, Bambara, Bashkir, Basque, Batak Karo, Batak Simalungun, Batak Toba, Belarusian, Bemba, Bengali, Betawi, Bhojpuri, Bikol, Bodo, Bosnian, Breton, Bulgarian, Burmese, Buryat, Cantonese, Catalan, Cebuano, Chhattisgarhi, Chichewa, Chinese (Simplified), Chinese (Traditional), Chuvash, Corsican, Crimean Tatar, Croatian, Czech, Danish, Dari, Dinka, Divehi, Dogri, Dombe, Dutch, Dzongkha, English, English (UK), English (Australia), Esperanto, Estonian, Ewe, Faroese, Fijian, Finnish, French, French (Canada), Frisian, Fulfulde, Ga, Galician, Ganda, Georgian, German, Greek, Guarani, Gujarati, Haitian Creole, Hakha Chin, Hausa, Hawaiian, Hebrew, Hiligaynon, Hindi, Hmong, Hungarian, Hunsrik, Icelandic, Igbo, Iloko, Indonesian, Inuinnaqtun, Inuktitut, Irish, Italian, Japanese, Javanese, Kannada, Kapampangan, Kashmiri, Kazakh, Khmer, Kiga, Kinyarwanda, Kituba, Konkani, Korean, Krio, Kurdish, Kurdish (Central), Kyrgyz, Laotian, Latgalian, Latin, Latvian, Ligurian, Limburgan, Lingala, Lithuanian, Lombard, Lower Sorbian, Luo, Luxembourgish, Macedonian, Maithili, Makassar, Malagasy, Malay, Malayalam, Maltese, Manipuri, Maori, Marathi, Meadow Mari, Minang, Mizo, Mongolian, Ndebele (South), Nepalbhasa, Nepali, Northern Sotho, Norwegian, Nuer, Occitan, Odia, Oromo, Pangasinan, Papiamento, Pashto, Persian, Polish, Portuguese, Portuguese (Brazil), Portuguese (Portugal), Punjabi, Quechua, Queretaro Otomi, Romani, Romanian, Rundi, Samoan, Sango, Sanskrit, Scottish Gaelic, Serbian, Sesotho, Seychellois Creole, Shan, Shona, Sicilian, Silesian, Sindhi, Sinhala, Slovak, Slovenian, Somali, Spanish, Spanish (Mexico), Spanish (United States), Sundanese, Swahili, Swati, Swedish, Tagalog, Tahitian, Tajik, Tamil, Tatar, Telugu, Tetum, Thai, Tibetan, Tigrinya, Tongan, Tsonga, Tswana, Turkish, Turkmen, Twi, Ukrainian, Upper Sorbian, Urdu, Uyghur, Uzbek, Vietnamese, Welsh, Xhosa, Yiddish, Yoruba, Yucatec Maya, Zulu 110 111 **Custom languages & dialects:** Choose from regional variants including English (UK, Australia), French (Canada), Spanish (US, Mexico), Portuguese (Brazil, Portugal), and Arabic (Egypt, UAE) 112 112 113 113 ==Pricing== … … 218 218 219 219 == Changelog == 220 = 269.6 = 221 * Dialects + fixes added 222 220 223 = 269.5 = 221 224 * Instructions for Exclusion pages added … … 621 624 With the most advanced “Extreme plan,” you have 100 languages at your disposal. 622 625 623 The current number of possible languages to operate in is 20 0.626 The current number of possible languages to operate in is 208. 624 627 625 628 While this list contains all the most-spoken languages of the world, many rare dialects are not yet included.
Note: See TracChangeset
for help on using the changeset viewer.