Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我必须建立一个多语言网站。在互联网上搜索时,我发现了 3 种方法。
你认为最好和更有效的方法是什么?我需要使用 SEO 技术,我正在使用 php、javascript。我正在建立的网站很大,并且有足够的文本可供翻译。
我使用第 4 种方式 - gettext及其相关的 PHP 库。似乎比提到的任何其他技术都简单得多——在代码中完全没有复杂化的意义上。在您的代码中,您只需编写:
<?php echo _("Hello world"); echo _("This is an english message."); ?>
就是这样!然后在一些初始化代码中我有:
bindtextdomain ('messages', './lang'); textdomain('messages');
在目录 ./lang 我有 gettext 翻译文件。