public void MergeAllTranslation(IDictionary <string, TemplateItem> items) { foreach (var language in _repository.GetAvailableLanguages()) { MergeTranslation(items, _repository.GetTranslation(language.LanguageShortTag)); } }
public void MergeAllTranslation(IDictionary <string, TemplateItem> items) { foreach (var language in _repository.GetAvailableLanguages()) { var filesNames = items.GroupBy(x => x.Value.FileName).Select(x => x.Key).ToList(); MergeTranslation(items, _repository.GetTranslation(language.LanguageShortTag, filesNames, false)); } }
public virtual ConcurrentDictionary <string, LanguageTag> GetAppLanguages() { ConcurrentDictionary <string, LanguageTag> AppLanguages = (ConcurrentDictionary <string, LanguageTag>)System.Web.HttpRuntime.Cache["i18n.AppLanguages"]; if (AppLanguages != null) { return(AppLanguages); } lock (Sync) { AppLanguages = (ConcurrentDictionary <string, LanguageTag>)System.Web.HttpRuntime.Cache["i18n.AppLanguages"]; if (AppLanguages != null) { return(AppLanguages); } AppLanguages = new ConcurrentDictionary <string, LanguageTag>(); // Insert into cache. // NB: we do this before actually populating the collection. This is so that any changes to the // folders before we finish populating the collection will cause the cache item to be invalidated // and hence reloaded on next request, and so will not be missed. System.Web.HttpRuntime.Cache.Insert("i18n.AppLanguages", AppLanguages, _translationRepository.GetCacheDependencyForAllLanguages()); // Populate the collection. List <string> languages = _translationRepository.GetAvailableLanguages().Select(x => x.LanguageShortTag).ToList(); // Ensure default language is included in AppLanguages where appropriate. if (LocalizedApplication.Current.MessageKeyIsValueInDefaultLanguage && !languages.Any(x => LocalizedApplication.Current.DefaultLanguageTag.Equals(x))) { languages.Add(LocalizedApplication.Current.DefaultLanguageTag.ToString()); } foreach (var langtag in languages) { if (IsLanguageValid(langtag)) { AppLanguages[langtag] = LanguageTag.GetCachedInstance(langtag); } } // Done. return(AppLanguages); } }