这是一个简单的方法来翻译你的网站使用PHP。这个想法是为你想要提供的每一种语言准备好几个文件。这些文件中的每一个都有ISO代码和txt扩展名。在这个演示中,我只使用德语作为网站默认语言的替代语言——英语。这些文件的内容是用他们的翻译形式写的单词和句子:
word=translation
所提供的PHP类将解析这个文件,创建一个映射两个单词和它的翻译对的数组。您只需要在php代码中插入以下内容:
$translate = new Translator($outputlanguage);
//$outputlanguage: ISO code (example: de,en,...) --> these are the names of each file
$translate->__('word to translate');
举个例子:
<h2><?php $translate->__('Registration'); ?></h2>
在您的txt文件中,我们将拥有:
Registration=Registrierung
特别声明:以上内容(如有图片或视频亦包括在内)为自媒体平台“网易号”用户上传并发布,本平台仅提供信息存储服务。
Notice: The content above (including the pictures and videos if any) is uploaded and posted by a user of NetEase Hao, which is a social media platform and only provides information storage services.