Domanda

I'm trying to get the language from the current node but are unable to get this working.

umbraco.cms.businesslogic.web.Domain.GetDomainsById(
    umbraco.uQuery.GetCurrentNode().Id
).Id

This will return 0 at all times. Any advice where to start looking or are there other methods to acquire the current language id, thanks!

È stato utile?

Soluzione

After some extensive digging in the well functioning dictionary classes I found the UmbracoCultureDictionary library that contains useful stuff like this

new umbraco.MacroEngines.UmbracoCultureDictionary().Language.id

Currently obsoleted and the referenced class Umbraco.Web.Dictionary.DefaultCultureDictionary is Internal, hence the following approach is probably the most compatible at the moment

umbraco.cms.businesslogic.language.Language.GetByCultureCode(
    System.Threading.Thread.CurrentThread.CurrentUICulture.Name
).id 

umbraco.cms.businesslogic.language.Language.GetByCultureCode(
    System.Threading.Thread.CurrentThread.CurrentUICulture.Name
).FriendlyName

umbraco.cms.businesslogic.language.Language.GetByCultureCode(
    System.Threading.Thread.CurrentThread.CurrentUICulture.Name
).CultureAlias
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top