Get CMS Culture
# help-with-umbraco
y
How can I Get CMS Culture by code? I want to get the current language that is the user work in by C# like : if user work on English get English if user work on French get French ...etc ?
r
I believe you can retrieve what culture (and therefore language) is being used in a template via
CultureInfo.CurrentUICulture
, which is in the
System.Globalization
namespace in C#
y
@Rachel D What I am trying to do is retrieve what culture that is the current user work on , but not in the template
j
If you have domains specified with cultures on the root level, and have a node context then you can do node.GetCultureFromDomains()
y
Hi @Jemayn , I did not got it , Could you provide me some sources?
j
Think you need to provide more context about what you are trying to do, and from within what kind of code you are doing it
y
@Jemayn I am trying to call an API , I create a custom property that call API and fetch the data , so what I am trying is fitch the data by the culture, the proerety take the api so if I provide the language in the API it will be for all the same data, for that I want to catch the current language for the cms to edit on the api and call by the language
j
Ahh ok, if it is from within the context of a custom property editor, then you can get it from the route, for multilingual content the culture of the content you are currently working on is added in the url via the mculture param. You can inject $routeParams into the controller and then call
$routeParams.mculture
But be aware that for split view editing there is currently no way of knowing which of the 2 you are calling your editor from - can't remember if the mculture param is from the initial or the newly opened split view version of the node
24 Views