翻译网站的最佳方式? [英] Best way to translate a website?

查看:41
本文介绍了翻译网站的最佳方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网站中,HTML 和 JS 代码中有几个英文字符串(不在数据库中),我需要将这些字符串翻译成其他语言(西班牙语、意大利语等).

In my website there are several english strings in the HTML and JS code ( NOT in the database ) and I need to translate these strings in others languages ( spanish, italian, etc ).

最好的方法是什么?

我可以在有语言的地方保存一个 cookie,但我可以把这些翻译后的字符串放在哪里?

I can save a cookie where there is the language but where can I put these translated strings ?

推荐答案

如果你不使用像 symfony2 这样的框架(它有一个名为 translation) 或 Zend(我确信会有一些可修正的独立组件"),实现这一点的一种方法是保留一个 php带有键=> 值对(或更好的数组)的文件,并将该文件包含在您的页面上.这样,您可以每次查找,然后加载正确"的标签和类似...

If you don't use a framework like, for instance, symfony2 (that have a component called translation) or Zend (that i'm sure will have some corrispective standalone "component"), a way for achive this is to keep a php file with key=> value pairs (or better, an array) and include that file onto your page. In that way, you could lookup everytime and, then, load the "right" labels and similar ...

另外,symfony2 翻译组件可以作为一个独立的部分使用,所以看看它是否能满足您的需求.

Also, symfony2 translation component could be used as a standalone part so take a look if it could satisfy your needs.

这篇关于翻译网站的最佳方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆