Created
July 15, 2016 13:19
-
-
Save wiedikerli/b2fe35271d6ddee4a38a07e6b6dfc4d1 to your computer and use it in GitHub Desktop.
Umbraco nuPickers DataSource for a language picker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using nuPickers.Shared.DotNetDataSource; | |
using System.Collections.Generic; | |
using System.Linq; | |
using Umbraco.Web; | |
namespace Opten.NAMESPACE.Web.DataSources | |
{ | |
public class LanguagePickerDataSource : IDotNetDataSource | |
{ | |
IEnumerable<KeyValuePair<string, string>> IDotNetDataSource.GetEditorDataItems(int contextId) | |
{ | |
var list = Enumerable.Empty<KeyValuePair<string, string>>().ToList(); | |
var localizationService = UmbracoContext.Current.Application.Services.LocalizationService; | |
var languages = localizationService.GetAllLanguages(); | |
foreach (var language in languages) | |
{ | |
list.Add(new KeyValuePair<string, string>(language.Id.ToString(), language.CultureInfo.DisplayName)); | |
} | |
return list; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment