0
Naren created
HI, I am using ABP5.3 Blazor server app and I have language filter in the application for the user to select and I need the selected language to filter the dropdown based on the selected language I have some custom tables/code that needs list based on language filter. How do I get that in code to filter?
1 Answer(s)
-
0
Hi @Naren
If you ask current language of current requrest, you can access
CultureInfo.CurrentCulture
If do you want to list of all languages of the application, you can inject
ILanguageProvider
and access localization options by callingGetLanguagesAsync()
method on it.public class MyService : ITransientDependency { protected ILanguageProvider LanguageProvider { get; } public MyService(ILanguageProvider languageProvider) { LanguageProvider = languageProvider; } public async Task DoSomethingAsync() { var languages = await LanguageProvider.GetLanguagesAsync(); var currentLanguage = languages.FindByCulture( CultureInfo.CurrentCulture.Name, CultureInfo.CurrentUICulture.Name); // ... } }