I'm on a 6.2.4 version of Umbraco and I'm doing some funky navigation elements.
Part of it is to create a language switch link.
For that I'm looping through the root nodes in the site, trying to get their Language setting. The problem I'm having is the culture always comes back as the current culture I'm in rather that being able to ask Umbraco for the culture of a specific node.
I don't and can't have domains set in the root nodes, but I do have languages set.
This is the closest thing I can find, but it seems to only run from the current context.
CultureInfo.CurrentCulture.Name
Any help would be much appreciated. So how do I get the language by NodeID?
To solve this on 6.2.4, I had to make sure the root site node was named correctly after a valid language culture name, and invoke a the CultureInfo class.
Code here on how to do it, though it does rely on Umbraco users correctly naming the root node.
Per - thanks for your responses, it would have been nice if the ".Language" function was implemented in v6.2.4 :(
var languagePrefix = siteRootNode.Name.Split('-').FirstOrDefault();
var ci = new CultureInfo(siteRootNode.Name);
var siteTitle = "view this site in " + ci.DisplayName;
How to get the culture of a node by ID
Hi all,
I'm on a 6.2.4 version of Umbraco and I'm doing some funky navigation elements.
Part of it is to create a language switch link.
For that I'm looping through the root nodes in the site, trying to get their Language setting. The problem I'm having is the culture always comes back as the current culture I'm in rather that being able to ask Umbraco for the culture of a specific node.
I don't and can't have domains set in the root nodes, but I do have languages set.
This is the closest thing I can find, but it seems to only run from the current context.
Any help would be much appreciated. So how do I get the language by NodeID?
Neil
The .Language property should do it. It will return the country code for the selected language, e.g. en-US.
https://our.umbraco.org/documentation/Reference/Management-v6/Models/Content
Hi Per,
Thanks for the response - unfortunately the .language feature has not been implemented into 6.2.4.
Do you know of any old-school methods that may work??
Thanks
Neil
To solve this on 6.2.4, I had to make sure the root site node was named correctly after a valid language culture name, and invoke a the CultureInfo class.
Code here on how to do it, though it does rely on Umbraco users correctly naming the root node.
Per - thanks for your responses, it would have been nice if the ".Language" function was implemented in v6.2.4 :(
Might help others who have the same challenge.
is working on a reply...