public ActionResult LanguageSelector()
        {
            var availableLanguages = _cacheManager.Get(string.Format(ModelCacheEventConsumer.AVAILABLE_LANGUAGES_MODEL_KEY, _storeContext.CurrentStore.Id), () =>
            {
                var result = _languageService
                    .GetAllLanguages(storeId: _storeContext.CurrentStore.Id)
                    .Select(x => new LanguageModel()
                    {
                        Id = x.Id,
                        Name = x.Name,
                        FlagImageFileName = x.FlagImageFileName,
                    })
                    .ToList();
                return result;
            });

            var model = new LanguageSelectorModel()
            {
                CurrentLanguageId = _workContext.WorkingLanguage.Id,
                AvailableLanguages = availableLanguages,
                UseImages = _localizationSettings.UseImagesForLanguageSelection
            };

            if (model.AvailableLanguages.Count == 1)
                Content("");

            return PartialView(model);
        }
Пример #2
0
 public ActionResult LanguageSelector()
 {
     var model = new LanguageSelectorModel()
     {
         CurrentLanguage = _workContext.WorkingLanguage.ToModel(),
         AvailableLanguages = _languageService.GetAllLanguages().Select(x => x.ToModel()).ToList(),
         UseImages = _localizationSettings.UseImagesForLanguageSelection
     };
     return PartialView(model);
 }
Пример #3
0
 private LanguageSelectorModel PrepareLanguageSelectorModel()
 {
     var model = new LanguageSelectorModel()
     {
         CurrentLanguage = _workContext.WorkingLanguage.ToModel(),
         AvailableLanguages = _languageService.GetAllLanguages().Select(x => x.ToModel()).ToList(),
         UseImages = _localizationSettings.UseImagesForLanguageSelection
     };
     return model;
 }
Пример #4
0
        protected LanguageSelectorModel PrepareLanguageSelectorModel()
        {
            var availableLanguages = _cacheManager.Get(ModelCacheEventConsumer.AVAILABLE_LANGUAGES_MODEL_KEY, () =>
            {
                var result = _languageService
                    .GetAllLanguages()
                    .Select(x => new LanguageModel()
                    {
                        Id = x.Id,
                        Name = x.Name,
                        FlagImageFileName = x.FlagImageFileName,
                    })
                    .ToList();
                return result;
            });

            var model = new LanguageSelectorModel()
            {
                CurrentLanguageId = _workContext.WorkingLanguage.Id,
                AvailableLanguages = availableLanguages,
                UseImages = _localizationSettings.UseImagesForLanguageSelection
            };
            return model;
        }