protected virtual IEnumerable <CurrentLanguageContent> GetLanguageBranches(ContentReference contentLink) { bool isSpecificLanguage = !string.IsNullOrWhiteSpace(this.SitemapData.Language); if (isSpecificLanguage) { LanguageSelector languageSelector = !this.SitemapData.EnableLanguageFallback ? new LanguageSelector(this.SitemapData.Language) : LanguageSelector.Fallback(this.SitemapData.Language, false); IContent contentData; if (this.ContentRepository.TryGet(contentLink, languageSelector, out contentData)) { return(new[] { new CurrentLanguageContent { Content = contentData, CurrentLanguage = new CultureInfo(this.SitemapData.Language), MasterLanguage = GetMasterLanguage(contentData) } }); } return(Enumerable.Empty <CurrentLanguageContent>()); } if (this.SitemapData.EnableLanguageFallback) { return(GetFallbackLanguageBranches(contentLink)); } return(this.ContentRepository.GetLanguageBranches <IContent>(contentLink).Select(x => new CurrentLanguageContent { Content = x, CurrentLanguage = GetCurrentLanguage(x), MasterLanguage = GetMasterLanguage(x) })); }
protected virtual IEnumerable <CurrentLanguageContent> GetFallbackLanguageBranches(ContentReference contentLink) { foreach (var languageBranch in this.EnabledLanguages) { var languageContent = ContentRepository.Get <IContent>(contentLink, LanguageSelector.Fallback(languageBranch.Culture.Name, false)); if (languageContent == null) { continue; } yield return(new CurrentLanguageContent { Content = languageContent, CurrentLanguage = languageBranch.Culture, MasterLanguage = GetMasterLanguage(languageContent) }); } }
protected virtual IEnumerable <HrefLangData> GetHrefLangData(ContentReference contentLink) { foreach (var languageBranch in this.EnabledLanguages) { var languageContent = ContentRepository.Get <IContent>(contentLink, LanguageSelector.Fallback(languageBranch.Culture.Name, false)); if (languageContent == null || ContentFilter.ShouldExcludeContent(languageContent)) { continue; } var hrefLangData = CreateHrefLangData(contentLink, languageBranch.Culture, GetMasterLanguage(languageContent)); yield return(hrefLangData); if (hrefLangData.HrefLang == "x-default") { yield return(new HrefLangData { HrefLang = languageBranch.Culture.Name.ToLowerInvariant(), Href = hrefLangData.Href }); } } }