在 Silverstripe 中自动生成 SiteTree 翻译
有没有办法(自动)生成或“复制”站点树以翻译成另一种语言? 例如通过 url 命令或类似的命令。
谨致问候, 贝内迪克特
Is there a way, to (automatically) generate, or "duplicate", the site tree for a translation into another language? For example via an url command or something like that.
Best regards,
Benedikt
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您现在可能已经找到了解决方案...但为了将来的参考,SilverStripe 用户 drx 已经创建了一个批量翻译操作,如下所述:http://silverstripe.org/customising-the-cms/show/7318
you probably already found a solution by now ... but for future reference, SilverStripe user drx has created a batch action for translations as discussed here: http://silverstripe.org/customising-the-cms/show/7318
提示:
->createTranslation()
仅创建实时记录,即使您在使用以下命令创建的舞台对象上调用此方法:要创建舞台和实时页面,您必须:
保存会自动完成两种情况。
Tip:
->createTranslation()
only creates a live-record even if you call this on a stage-object created with:To create Stage and Live-Pages you have to:
Saving is done automatically in both cases.
您不会复制站点树来创建翻译。 SilverStripe 支持多语言网站。您可以在这里阅读:http://doc.silverstripe.org/sapphire/en /topics/translation
如果您想要一种自动执行此操作的方法,则没有本机支持,但这并不难做到。通过 URL 只需向您的 Page_Controller 添加一个函数,或者更好的是,如果您要定期执行此操作,您可以编写一个简单的模块(只需查看 googlesitemaps 模块作为示例,因为它循环通过您需要的页面)。您可以通过调用以下命令来获取所有页面:
然后您将在循环时创建翻译。您还可以使用 SilverStripe 的 CMDline 实用程序“sake”通过命令行执行此操作: http://doc .silverstripe.org/sapphire/en/topics/commandline
You wouldn't duplicate the site tree to create a translation. SilverStripe supports multi-lingual sites. You can read up on it here: http://doc.silverstripe.org/sapphire/en/topics/translation
If you're wanting a way to automate this there's no native support but it wouldn't be hard to do. By URL would just be a matter of adding a function to your Page_Controller or, even better, you could write a simple module if it's something you're going to be doing regularly (just look at the googlesitemaps module for an example as it loops through pages as you'd need to). You can get all pages by calling:
Then you'd create your translation(s) as you looped through. You could also do this via commandline by using SilverStripe's CMDline utility "sake": http://doc.silverstripe.org/sapphire/en/topics/commandline