网站翻译onload [英] Website translation onload

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

问题描述

我有一个约会网站,目前使用英语。
根据客户要求,他告诉我用波兰语翻译网站。
如果我要为网站创建语言文件,那么我需要对整个项目进行修改。
是否有任何技术可以使我的网站在浏览器中加载时自动翻译成波兰语。当特定事件发生时,还会显示一些隐藏的div。

I have a dating site which is currently in English language. As per client requirement he told me to convert the website in Polish language. If I will create language file for the website, then I need to rework on whole project. Is there any technique so that my website is automatically translated into Polish language when it is loading in browser. There also some hidden div's that will be displayed when a specific event occurs.

该网站是在php中创建的,具有聪明的模板。

The website is created in php with smarty templating.

请帮助我。

谢谢

推荐答案

如果你想要一个自定义解决方案,你将需要对你当前的代码进行一些编辑。

If you want a custom solution, you're going to have to do some editing of your current code.

选项1

将所有字符串存储在 YAML 文件中或在数据库或平面文件中,或者您希望它们存储。事实是,只要你的应用程序加载,它就会在数据库中查询你的语言中的字符串(你的url最后会有/ en,/ fr,/ de等)并将它们放到你的页面。

Store all your strings in YAML files or within a database, or flat file, or however else you want them stored. The fact of the matter is that, as soon as your application loads, it'll query the database for the strings in your language (your url will have /en, /fr, /de etc at the end) and place those onto your page.

这意味着您必须对此数据的检索以及在您的应用程序中的位置进行编码。

This means you'll have to code the retrieval of this data, and placement within your application.

选项2

使用Google的自动翻译根据Dainis在评论中的建议。这不是可自定义的,但意味着您无需对当前代码进行任何重新处理。

Use Google's "Auto Translate" as per Dainis' suggestion in the comments. This isn't as customisable, but means you don't have to do any reworking of your current code.

选项3

使用 Bing的翻译API 并手动请求您希望在每个请求中翻译的数据的字符串。开发人员可以免费访问Bing API,并且包含大量免费翻译 - 但这将是数据密集型的,除非您缓存翻译以备将来使用。

Use Bing's translate API and manually request strings for the data you want translated on each request. Access to the Bing API is free for developers and has loads of free translations included - but this will be data intensive unless you cache the translations for future use.

使用选项3,您仍然需要编写自己的自定义解决方案。因此,如果您处于紧迫的截止日期或者您只是懒惰,请使用选项2。

With Option 3, you'll still have to code your own custom solution. So if you're on a tight deadline or you're just plain lazy, go with Option 2.

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

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