Cakephp 网站对同一数据库提供英语和阿拉伯语支持
我正在使用 CakePHP 1.3 构建一个网站。我的要求是有一个支持阿拉伯语和英语的网站。我希望如果用户以阿拉伯语输入信息,那么当英语用户看到相同的信息时,它应该是英语,反之亦然。
至于本地化标签,我是使用 po 文件完成的。它非常简单。 但对于数据库,我使用 Cakephp 的内置翻译行为。但它同样不会翻译任何内容,而是使用当前正在使用的区域设置创建另一个数据副本。
请帮助我应该朝哪个方向移动。
我想知道这种情况下应遵循的最佳实践。 翻译数据库值可能不是最好的解决方案,应该以它们即将出现的任何语言保存这些值。
任何帮助和建议将不胜感激。
Im building a website in CakePHP 1.3. My requirement is to have a website with arabic and english support. I want that if a user is entering the information in arabic so when the english user sees the same information it should be in english and vice versa.
As far as localing the labels ive done that using po files. Its pretty straight forward.
But for the database im using the Cakephp's built-in Translate Behaviour. But it again doesn't translate anything and creates another copy of the data with the current locale that is in use.
Please help me in which direction i should move.
I want to know the best practices that should be followed for this kind of scenario.
May be translating db values is not the best solution and should save the values as in whatever language they are coming.
Any help and suggestions would be highly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上不可能让 CakePHP 自动翻译输入的数据。
翻译行为允许您以多种语言输入相同的内容,然后根据您当前在配置中设置的语言从数据库中检索适当的语言。它实际上不会为您翻译任何内容。
理论上,您可以向 Model::beforeSave() 回调添加一个函数,该函数会将阿拉伯文本提交到 Google Translate 等服务,然后将阿拉伯语和英语版本保存到相应的表中,但结果不一定非常好。好的。正如@deceze 在对你的问题的评论中所说,机器翻译是一个难题。
It isn't actually possible to have CakePHP automatically translate data that is entered.
The Translate Behavior allows you to enter the same content in multiple languages and then retrieve the appropriate language from the database, based on the language that you currently have set in your config. It doesn't actually translate anything for you.
Theoretically, you could add a function to the Model::beforeSave() callback that would submit the Arabic text to a service like Google Translate and then save both Arabic and English versions to their appropriate tables, but the results won't necessarily be very good. As @deceze said in his comment to your question, machine translation is a hard problem.