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'];
722 private function patch_links($text, $target_lang, $ns): string {
736 preg_match_all('/\[\[([\s\S]*?)(#[\s\S]*?)?((\|)([\s\S]*?))?]]/', $text, $matches, PREG_SET_ORDER);
775 $text = str_replace($match[0], $new_link, $text);
783 preg_match_all('/\{\{(([\s\S]*?)(\?[\s\S]*?)?)(\|([\s\S]*?))?}}/', $text, $matches, PREG_SET_ORDER);
828 $text = str_replace($match[0], $new_link, $text);
832 return $text;
835 private function insert_ignore_tags($text): string {
837 $text = preg_replace('/<[\s\S]+?>/', '<ignore>${0}</ignore>', $text);
840 $text = preg_replace('/={1,6}/', '<ignore>${0}</ignore>', $text);
843 $text = str_replace("~~NOCACHE~~", "<ignore>~~NOCACHE~~</ignore>", $text);
846 $text = preg_replace('/\{\{[\s\w]+?>[\s\S]*?}}/', '<ignore>${0}</ignore>', $text);
849 $text = preg_replace('/\S+:\/\/\S+/', '<ignore>${0}</ignore>', $text);
851 // ignore link/media ids but translate the text (if existing)
852 $text = preg_replace('/\[\[([\s\S]*?)(#[\s\S]*?)?((\|)([\s\S]*?))?]]/', '<ignore>[[${1}${2}${4}</ignore>${5}<ignore>]]</ignore>', $text);
853 $text = preg_replace('/\{\{([\s\S]*?)(\?[\s\S]*?)?((\|)([\s\S]*?))?}}/', '<ignore>{{${1}${2}${4}</ignore>${5}<ignore>}}</ignore>', $text);
856 $text = str_replace(" ^ ", "<ignore> ^ </ignore>", $text);
857 $text = str_replace(" ^ ", "<ignore> ^ </ignore>", $text);
858 $text = str_replace(" ^ ", "<ignore> ^ </ignore>", $text);
859 $text = str_replace("^ ", "<ignore>^ </ignore>", $text);
860 $text = str_replace(" ^", "<ignore> ^</ignore>", $text);
861 $text = str_replace("^", "<ignore>^</ignore>", $text);
862 $text = str_replace(" | ", "<ignore> | </ignore>", $text);
863 $text = str_replace(" | ", "<ignore> | </ignore>", $text);
864 $text = str_replace(" | ", "<ignore> | </ignore>", $text);
865 $text = str_replace("| ", "<ignore>| </ignore>", $text);
866 $text = str_replace(" |", "<ignore> |</ignore>", $text);
867 $text = str_replace("|", "<ignore>|</ignore>", $text);
871 $text = str_replace("''", "<ignore><ignore>''</ignore></ignore>", $text);
872 $text = str_replace("//", "<ignore><ignore>//</ignore></ignore>", $text);
873 $text = str_replace("**", "<ignore><ignore>**</ignore></ignore>", $text);
874 $text = str_replace("__", "<ignore><ignore>__</ignore></ignore>", $text);
875 $text = str_replace("\\\\", "<ignore><ignore>\\\\</ignore></ignore>", $text);
880 $text = str_replace($smiley, "<ignore>" . $smiley . "</ignore>", $text);
884 $text = preg_replace('/(<php[\s\S]*?>[\s\S]*?<\/php>)/', '<ignore>${1}</ignore>', $text);
885 $text = preg_replace('/(<file[\s\S]*?>[\s\S]*?<\/file>)/', '<ignore>${1}</ignore>', $text);
886 $text = preg_replace('/(<code[\s\S]*?>[\s\S]*?<\/code>)/', '<ignore>${1}</ignore>', $text);
892 $text = str_replace($expression, '<ignore>' . $expression . '</ignore>', $text);
895 return $text;
898 private function remove_ignore_tags($text): string {
902 $text = str_replace('<ignore>' . $expression . '</ignore>', $expression, $text);
906 $text = str_replace("<ignore>~~NOCACHE~~</ignore>", "~~NOCACHE~~", $text);
909 $text = str_replace("<ignore>^</ignore>", "^", $text);
910 $text = str_replace("<ignore>^ </ignore>", "^ ", $text);
911 $text = str_replace("<ignore> ^</ignore>", " ^", $text);
912 $text = str_replace("<ignore> ^ </ignore>", " ^ ", $text);
913 $text = str_replace("<ignore> ^ </ignore>", " ^ ", $text);
914 $text = str_replace("<ignore> ^ </ignore>", " ^ ", $text);
915 $text = str_replace("<ignore>|</ignore>", "|", $text);
916 $text = str_replace("<ignore>| </ignore>", "| ", $text);
917 $text = str_replace("<ignore> |</ignore>", " |", $text);
918 $text = str_replace("<ignore> | </ignore>", " | ", $text);
919 $text = str_replace("<ignore> | </ignore>", " | ", $text);
920 $text = str_replace("<ignore> | </ignore>", " | ", $text);
922 $text = str_replace("<ignore><ignore>''</ignore></ignore>", "''", $text);
923 $text = str_replace("<ignore><ignore>//</ignore></ignore>", "//", $text);
924 $text = str_replace("<ignore><ignore>**</ignore></ignore>", "**", $text);
925 $text = str_replace("<ignore><ignore>__</ignore></ignore>", "__", $text);
926 $text = str_replace("<ignore><ignore>\\\\</ignore></ignore>", "\\\\", $text);
929 $text = preg_replace('/<ignore>(\S+:\/\/\S+)<\/ignore>/', '${1}', $text);
931 $text = preg_replace('/<ignore>\[\[([\s\S]*?)(\|)?(<\/ignore>)([\s\S]*?)?<ignore>]]<\/ignore>/', '[[${1}${2}${4}]]', $text);
932 $text = preg_replace('/<ignore>\{\{([\s\S]*?)(\|)?(<\/ignore>)([\s\S]*?)?<ignore>}}<\/ignore>/', '{{${1}${2}${4}}}', $text);
937 $text = str_replace("<ignore>" . $smiley . "</ignore>", $smiley, $text);
940 $text = preg_replace('/<ignore>(<php[\s\S]*?>[\s\S]*?<\/php>)<\/ignore>/', '${1}', $text);
941 $text = preg_replace('/<ignore>(<file[\s\S]*?>[\s\S]*?<\/file>)<\/ignore>/', '${1}', $text);
942 $text = preg_replace('/<ignore>(<code[\s\S]*?>[\s\S]*?<\/code>)<\/ignore>/', '${1}', $text);
945 $text = preg_replace('/<ignore>(\{\{[\s\w]+?>[\s\S]*?}})<\/ignore>/', '${1}', $text);
948 $text = preg_replace('/<ignore>(={1,6})<\/ignore>/','${1}', $text);
951 $text = preg_replace('/<ignore>(<[\s\S]+?>)<\/ignore>/', '${1}', $text);
954 $text = str_replace('&gt;', '>', $text);
955 $text = str_replace('&lt;', '<', $text);
958 $text = str_replace('&amp;', '&', $text);
960 return $text;