如何像 google 翻译器一样使用 php 创建快速翻译器?
how to create a fast translator using php like google translator?
我想翻译我网站上的文字,例如 google 翻译(不是用它)。我只需要一个示例 php 代码来翻译一些定义的单词(而不是整个语言)。
这是我的示例代码:
$text = "hello john";
$translated_text = str_replace("hello", 'Hallo', $text);
echo $translated_text;
</pre>
它在服务器上执行速度快吗?
我必须逐字翻译吗?
您需要填写字典才能查找要翻译的单词。
看看 this answer,该代码旨在过滤不良词,但应该适用于您的情况。
我想翻译我网站上的文字,例如 google 翻译(不是用它)。我只需要一个示例 php 代码来翻译一些定义的单词(而不是整个语言)。 这是我的示例代码:
$text = "hello john";
$translated_text = str_replace("hello", 'Hallo', $text);
echo $translated_text;
</pre>
它在服务器上执行速度快吗?
我必须逐字翻译吗?
您需要填写字典才能查找要翻译的单词。
看看 this answer,该代码旨在过滤不良词,但应该适用于您的情况。