Lines Matching refs:text

209         $translated_text = $this->deepl_translate($org_page_info["text"], $this->get_target_lang(), $org_page_info["ns"]);
230 $event->data['tpl'] = $this->deepl_translate($org_page_info["text"], $this->get_target_lang(), $org_page_info["ns"]);
372 return array("ns" => getNS($org_id), "text" => rawWiki($org_id));
644 private function deepl_translate($text, $target_lang, $org_ns): string {
650 $text = $this->patch_links($text, $target_lang, $org_ns);
652 $text = $this->insert_ignore_tags($text);
659 'text' => $text
707 $translated_text = $json_response['translations'][0]['text'];
740 private function patch_links($text, $target_lang, $ns): string {
754 preg_match_all('/\[\[([\s\S]*?)(#[\s\S]*?)?((\|)([\s\S]*?))?]]/', $text, $matches, PREG_SET_ORDER);
794 $text = str_replace($match[0], $new_link, $text);
802 preg_match_all('/\{\{(([\s\S]*?)(\?[\s\S]*?)?)(\|([\s\S]*?))?}}/', $text, $matches, PREG_SET_ORDER);
849 $text = str_replace($match[0], $new_link, $text);
853 return $text;
856 private function insert_ignore_tags($text): string {
858 $text = preg_replace('/<[\s\S]+?>/', '<ignore>${0}</ignore>', $text);
861 $text = preg_replace('/={1,6}/', '<ignore>${0}</ignore>', $text);
864 $text = str_replace("~~NOCACHE~~", "<ignore>~~NOCACHE~~</ignore>", $text);
867 $text = preg_replace('/\{\{[\s\w]+?>[\s\S]*?}}/', '<ignore>${0}</ignore>', $text);
870 $text = preg_replace('/\S+:\/\/\S+/', '<ignore>${0}</ignore>', $text);
872 // ignore link/media ids but translate the text (if existing)
873 $text = preg_replace('/\[\[([\s\S]*?)(#[\s\S]*?)?((\|)([\s\S]*?))?]]/', '<ignore>[[${1}${2}${4}</ignore>${5}<ignore>]]</ignore>', $text);
874 $text = preg_replace('/\{\{([\s\S]*?)(\?[\s\S]*?)?((\|)([\s\S]*?))?}}/', '<ignore>{{${1}${2}${4}</ignore>${5}<ignore>}}</ignore>', $text);
877 $text = str_replace(" ^ ", "<ignore> ^ </ignore>", $text);
878 $text = str_replace(" ^ ", "<ignore> ^ </ignore>", $text);
879 $text = str_replace(" ^ ", "<ignore> ^ </ignore>", $text);
880 $text = str_replace("^ ", "<ignore>^ </ignore>", $text);
881 $text = str_replace(" ^", "<ignore> ^</ignore>", $text);
882 $text = str_replace("^", "<ignore>^</ignore>", $text);
883 $text = str_replace(" | ", "<ignore> | </ignore>", $text);
884 $text = str_replace(" | ", "<ignore> | </ignore>", $text);
885 $text = str_replace(" | ", "<ignore> | </ignore>", $text);
886 $text = str_replace("| ", "<ignore>| </ignore>", $text);
887 $text = str_replace(" |", "<ignore> |</ignore>", $text);
888 $text = str_replace("|", "<ignore>|</ignore>", $text);
892 $text = str_replace("''", "<ignore><ignore>''</ignore></ignore>", $text);
893 $text = str_replace("//", "<ignore><ignore>//</ignore></ignore>", $text);
894 $text = str_replace("**", "<ignore><ignore>**</ignore></ignore>", $text);
895 $text = str_replace("__", "<ignore><ignore>__</ignore></ignore>", $text);
896 $text = str_replace("\\\\", "<ignore><ignore>\\\\</ignore></ignore>", $text);
901 $text = str_replace($smiley, "<ignore>" . $smiley . "</ignore>", $text);
905 $text = preg_replace('/(<php[\s\S]*?>[\s\S]*?<\/php>)/', '<ignore>${1}</ignore>', $text);
906 $text = preg_replace('/(<file[\s\S]*?>[\s\S]*?<\/file>)/', '<ignore>${1}</ignore>', $text);
907 $text = preg_replace('/(<code[\s\S]*?>[\s\S]*?<\/code>)/', '<ignore>${1}</ignore>', $text);
913 $text = str_replace($expression, '<ignore>' . $expression . '</ignore>', $text);
916 return $text;
919 private function remove_ignore_tags($text): string {
923 $text = str_replace('<ignore>' . $expression . '</ignore>', $expression, $text);
927 $text = str_replace("<ignore>~~NOCACHE~~</ignore>", "~~NOCACHE~~", $text);
930 $text = str_replace("<ignore>^</ignore>", "^", $text);
931 $text = str_replace("<ignore>^ </ignore>", "^ ", $text);
932 $text = str_replace("<ignore> ^</ignore>", " ^", $text);
933 $text = str_replace("<ignore> ^ </ignore>", " ^ ", $text);
934 $text = str_replace("<ignore> ^ </ignore>", " ^ ", $text);
935 $text = str_replace("<ignore> ^ </ignore>", " ^ ", $text);
936 $text = str_replace("<ignore>|</ignore>", "|", $text);
937 $text = str_replace("<ignore>| </ignore>", "| ", $text);
938 $text = str_replace("<ignore> |</ignore>", " |", $text);
939 $text = str_replace("<ignore> | </ignore>", " | ", $text);
940 $text = str_replace("<ignore> | </ignore>", " | ", $text);
941 $text = str_replace("<ignore> | </ignore>", " | ", $text);
943 $text = str_replace("<ignore><ignore>''</ignore></ignore>", "''", $text);
944 $text = str_replace("<ignore><ignore>//</ignore></ignore>", "//", $text);
945 $text = str_replace("<ignore><ignore>**</ignore></ignore>", "**", $text);
946 $text = str_replace("<ignore><ignore>__</ignore></ignore>", "__", $text);
947 $text = str_replace("<ignore><ignore>\\\\</ignore></ignore>", "\\\\", $text);
950 $text = preg_replace('/<ignore>(\S+:\/\/\S+)<\/ignore>/', '${1}', $text);
952 $text = preg_replace('/<ignore>\[\[([\s\S]*?)(\|)?(<\/ignore>)([\s\S]*?)?<ignore>]]<\/ignore>/', '[[${1}${2}${4}]]', $text);
953 $text = preg_replace('/<ignore>\{\{([\s\S]*?)(\|)?(<\/ignore>)([\s\S]*?)?<ignore>}}<\/ignore>/', '{{${1}${2}${4}}}', $text);
958 $text = str_replace("<ignore>" . $smiley . "</ignore>", $smiley, $text);
961 $text = preg_replace('/<ignore>(<php[\s\S]*?>[\s\S]*?<\/php>)<\/ignore>/', '${1}', $text);
962 $text = preg_replace('/<ignore>(<file[\s\S]*?>[\s\S]*?<\/file>)<\/ignore>/', '${1}', $text);
963 $text = preg_replace('/<ignore>(<code[\s\S]*?>[\s\S]*?<\/code>)<\/ignore>/', '${1}', $text);
966 $text = preg_replace('/<ignore>(\{\{[\s\w]+?>[\s\S]*?}})<\/ignore>/', '${1}', $text);
969 $text = preg_replace('/<ignore>(={1,6})<\/ignore>/','${1}', $text);
972 $text = preg_replace('/<ignore>(<[\s\S]+?>)<\/ignore>/', '${1}', $text);
975 $text = str_replace('&gt;', '>', $text);
976 $text = str_replace('&lt;', '<', $text);
979 $text = str_replace('&amp;', '&', $text);
981 return $text;