Hi i'm using DbLocalizationProvider in a selectionFactory to display the enabled languages in a dropdown.
But i was wondering if you could dynamically sent translation for a string to the DbLocalizationProvider instead of defined [LocalizedModel]/[LocalizedResource].
I want the editors to see the Text of the SelectItem in the language they are in. So translatable ...
public class CountrySelectionFactory : ISelectionFactory
public IEnumerable GetSelections(ExtendedMetadata metadata)
IList languages = ServiceLocator.Current.GetInstance()
.Select(lang => new LanguageSelector(lang.LanguageID))
return languages.Select(ls =>
Text = ls.Language.Name, //Want to translate this via DbLocalizationProvider
Value = ls.Language.TwoLetterISOLanguageName
Hi Vishal, did you check the documentation in GitHub? From the guide: Translating in C#
So you would have the locazation "view model" registered for the languages and then fetch the localized sting using the mentioned code.
Another option would be to ask the question in GitHub on the project so Valdis might spot the question instead of just having it here on the Episerver forums.
thanks for your comment, although i have checked github and understand the basic of the viewmodel. Only in my case the text i want to translate comes dynamically from all the languages in Episerver (enabled). So i was looking of a way to translate those.
I meant you would create a dummy view model where you would have the languages listed that you know will be supported and then you would need a mapping from language code for example to a property in the dummy view model. Sort of hack.
What if you just use the "NativeName" property on the CultureInfo object?