CakePHP:使用可翻译行为时,如何将英语作为后备语言?
当表中的某个条目没有翻译时,是否可以显示默认/英文翻译?提前致谢!
when a certain entry in a table has no translation, is it possible to display the default/english translation instead? Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我写了一个补丁来做到这一点不久前的事情。它只经过了少量测试,但可以在我的 Codaset 中的“Scratchpad”项目中使用。事实上,它只经过了少量测试,这就是它位于 Scratchpad 项目而不是其自己的项目中的原因。
除非/直到补丁应用于核心,否则我只是复制该文件(重命名行为
Translatable
并在我的app/models/behaviors/
目录中使用它。A <还提供了一个 href="http://codaset.com/robwilkerson/scratchpad/source" rel="nofollow noreferrer">README 文件,其中讨论了修改后的行为,请随时告诉我。输入错误等。正如我所说,它只是经过了轻微测试,所以 YMMV,当然,不提供或暗示任何保证:-)。
I wrote a patch to do this very thing a while back. It's only been lightly tested, but it's available in my "Scratchpad" project in Codaset. The fact that it's only lightly tested is the reason it's in the Scratchpad project rather than a project of its own.
Unless/until the patch is applied to core, I just copied the file (renaming the behavior
Translatable
and use it from within myapp/models/behaviors/
directory. A README file is also available that discusses the modified behavior.Let me know if it helps you. Feel free to enter bugs, etc. As I said, it's only lightly tested, so YMMV and, of course, no warranty is given or implied. :-)