我应该如何在 Sitecore 中存储/访问本地化 UI 字符串?
我正在向我的网站添加对多种语言的支持。我发现渲染器中的许多地方都有我需要解决的硬编码字符串。
我似乎有几个不同的选项来解决这个问题...其中之一是使用标准 .NET 方法并将字符串存储在资源文件中。我不喜欢这个,因为我的 Sitecore 翻译人员无法做到这一点...而且我认为 Sitecore 没有默认设置文化?我相信这就是 ASP.NET 从资源文件中知道要使用哪种语言的方式。
另一种选择是在我的 Sitecore 模板中添加所有这些字符串的字段,以便译者在内容编辑器中可以看到它们。但这似乎是一个巨大的麻烦......有很多很多地方我必须只更新我的模板来存储 UI 元素字符串。
还有其他 Sitecore 支持的选项吗?建议?我们目前使用的是 v6.2。
I'm adding support for multiple language to my site. I've found many places in my renderers that have hard-coded strings I'll need to address.
I seem to have a couple different options of fixing this... one would be to use the standard .NET approach and store strings in a resource file. I'm not liking this because my Sitecore translators can't get to that... and also because I don't think Sitecore sets the Culture by default? Which I believe is how ASP.NET knows which language to use from the resource file.
Another option would be to add fields for all these strings in my Sitecore templates so they are visible to translators in Content Editor. But this seems like a huge hassle... there are many, many places where I would have to update my templates solely to store UI element strings.
Are there any other Sitecore-supported options? Suggestions? We are currently on v6.2.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您可能应该看看使用 Sitecore 字典和/或令牌替换。我自己没有玩过它,但我认为它可以完成你需要做的工作。
请参阅重用数据指南第 12 页。
http://sdn.sitecore.net/upload/sitecore6/sc62keywords/reusing_and_sharing_data_sc62_a4001.pdf
我想您还可以尝试从 Sitecore 语言参数中显式设置区域性,并使用它来访问 .net 资源文件。资源文件本身可以通过 Sitecore 字典的 Sitecore 渲染来生成。这样,您就可以让编辑和翻译人员访问字符串以进行本地化,并使用开箱即用的 ASP.Net 将它们带入您的渲染中。
I think you should probably have a look at using a Sitecore dictionary and/or token substitution. Not played with it myself, but I think it could do the work you need to do.
See page 12 of the reusing data guide.
http://sdn.sitecore.net/upload/sitecore6/sc62keywords/reusing_and_sharing_data_sc62_a4001.pdf
I imagine you could also play with explicitly setting the culture from the Sitecore language parameter and using it to access a .net resource file. The resource file itself could be produced by a Sitecore rendering of the Sitecore dictionary. That way you'd give editors and translators access to the strings to localise and use out of the box ASP.Net to bring them into your renderings.