简体   繁体   English

Sitecore获取所有语言的列表

[英]Sitecore get list of all languages

How do I programatically get a list of all the languages available? 如何以编程方式获取所有可用语言的列表? I am using the following code: 我正在使用以下代码:

Item currentItem = GetCurrentItem();

LanguageCollection languages;
Database database = Context.ContentDatabase;
languages = LanguageManager.GetLanguages(database);

This does not return all the languages installed on the system and available in the languagedefinitions.config file. 这不会返回系统上安装的所有语言并在languagedefinitions.config文件中可用。

Any idea on how to get all the languages? 关于如何获得所有语言的任何想法?

If you want to get the list of all language definitions from the <languageDefinitions>/<languages> setting, you can use the following code: 如果要从<languageDefinitions>/<languages>设置获取所有语言定义的列表,则可以使用以下代码:

Sitecore.Globalization.LanguageDefinitions.Definitions

The code which you use ( LanguageManager.GetLanguages(database); ) returns languages which are in the selected database under the sitecore/system/languages node only. 您使用的代码( LanguageManager.GetLanguages(database); )返回的语言仅在sitecore/system/languages节点下的所选数据库中。

现在,我正在阅读languagedefinitions.config文件并以编程方式添加所有语言。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM