Pregunta

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!

¿Fue útil?

Solución

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
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top