Umbraco 7使用语言/词典 [英] Umbraco 7 Working with languages/Dictionary
问题描述
我们的项目终于到了可以添加翻译的地步.我似乎无法弄清楚如何真正地使用Umbraco 7中的语言.Ive在后端添加了一种语言和一些词典项,但是如何在代码中选择Givent语言?
Our project has finally come to a point where we can add translations. I just cant seem to figure out how to actually work with languages in Umbraco 7. Ive added a language and a few dictionary items in the backend, but how do i select the givent language in my code?
是否有任何帮助程序来获取API中的翻译?像DictionaryHelper.Translate("Answers","da-DK"); ?还是类似的?有没有一种方法可以在启动控制器中设置语言等,并且始终从词典中获取该语言?
Are there any helpers to get translations in the API? Like DictionaryHelper.Translate("Answers","da-DK"); ? Or similar? Is there a way to set the language, etc in the startup controller, and just always get that language from the dictionary?
先谢谢了. 乔纳斯.
推荐答案
首先,您必须在设置">语言"下创建语言.
First, you have to create your languages under Settings > Languages.
下一步是在每个节点上或仅在顶部节点上设置语言.因此,可以说您的内容树如下所示:"
Next step is to set the language on each node, or just on a top node. So lets say your content tree looks like this:"
然后右键单击"da",然后选择文化和主机名".为该节点选择"da-DK".现在,所有子节点(和"da"节点)都将使用丹麦语.
Then right click on "da" and select "Culture and Hostnames". Select "da-DK" for this node. All subnodes (and "da" node) will now have the danish language.
因此,现在很容易用剃刀和c#代码获取字典项.在剃须刀中:
So now its simple to get dictionary items in razor and c# code. In razor:
@Umbraco.GetDictionaryValue("Answers")
这篇关于Umbraco 7使用语言/词典的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!