Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hello,
I have a multi-language website with a domain and a subdomain configured for different languages with the 'culture and hostnames' options.
Dutch Homepage (nl-NL) - articles - article1 - article2
EnglishHomepage (en-US - articles - article1 - article2
How would I get the language code for a node/item/publishablecontent ?
I already found the solution here: http://our.umbraco.org/forum/developers/razor/43044-Get-language-in-Razor
var currentHomePage = CurrentPage.AncestorOrSelf(1);var language = Domain.GetDomainsById(currentHomePage.Id)[0].Language;
Hello
It's work fine when we have domain on node,
I have only culture defined on node without domain.
And ideas how can I get only node culture?
Yes I don't care about the domain, I want the language regardless of whether the domain is set. (nb: I don't need it for the current page, I want to build a list of hreflang links)
I've posted a solution that works with Umbraco 7.2.4 here: https://our.umbraco.org/forum/developers/razor/43044-Get-language-in-Razor?p=1 In the case if you don't use separate domains for different langauges.
It might work in 6 as well
public static CultureInfo GetCulture(IPublishedContent content) { List<IPublishedContent> ancestors = content.Ancestors().ToList(); Domain[] domains = Domain.GetDomains(true).ToArray<Domain>(); foreach(IPublishedContent cnt in ancestors) { Domain nodeDomain = domains.Where(d => d.RootNodeId == cnt.Id).FirstOrDefault(); if(nodeDomain != null) return new CultureInfo(nodeDomain.Language.CultureAlias); } return new CultureInfo(domains.First().Language.CultureAlias); }
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Getting language of a "node" in Umbraco 6
Hello,
I have a multi-language website with a domain and a subdomain configured for different languages with the 'culture and hostnames' options.
Dutch Homepage (nl-NL)
- articles
- article1
- article2
EnglishHomepage (en-US
- articles
- article1
- article2
How would I get the language code for a node/item/publishablecontent ?
I already found the solution here: http://our.umbraco.org/forum/developers/razor/43044-Get-language-in-Razor
Hello
It's work fine when we have domain on node,
I have only culture defined on node without domain.
And ideas how can I get only node culture?
Yes I don't care about the domain, I want the language regardless of whether the domain is set. (nb: I don't need it for the current page, I want to build a list of hreflang links)
I've posted a solution that works with Umbraco 7.2.4 here: https://our.umbraco.org/forum/developers/razor/43044-Get-language-in-Razor?p=1 In the case if you don't use separate domains for different langauges.
It might work in 6 as well
is working on a reply...