Correct way to get dictionary items in Controller ...
# help-with-other
m
What is the best practice to get dictionary item in a controller action now? I am thinking either localizationService or ContextAccessor, which is "heavier" to use? I still need to get the current language somehow right?
d
Hey, as far as I know, you should always get dictionary items through
UmbracoHelper
. In a
RenderController
, I think you automatically have access to an umbraco helper, but you could also inject
IUmbracoHelperAccessor
if you can't find it.
At least the Umbraco Helper automatically takes the current language from your request context, so you don't have to worry about that
s
this would have been a great question for #1125392773038755890 by the way 😇
s
inject ICultureDictionaryFactory and use that to create your CultureDictionary
thats (somewhat) what UmbracoHelper is doing
11 Views