Search code examples
razorlocalizationdotnetnuke

Dnn Razor Script Localization


I know how to localize regular DNN modules but I'm not sure where to begin with Razor Scripts hosted in the DNN Razor Host Module.

I keep my localization resx files in a separate assembly so I thought the easiest thing would be to the resources from the Assembly using the ResourceManager but this doesn't seem to tie in well with Dnn's localization framework, since the resources won't be editable in Dnn.

If at all possible I'd like to keep the resource files embedded but I would understand if that was not possible.

Either way, how do I access these resources in a Razor Script file in Dnn?


Solution

  • you can use this apporoach, but I'm not sure if it is what you looking for...

        @using DotNetNuke.Services.Localization
        @{
            var localResourceFile = "/DesktopModules/RazorModules/RazorHost/Scripts/App_LocalResources/SharedResources.ascx." + Dnn.Portal.CultureCode + ".resx";
            var text = Localization.GetString("pepamaca.Text", localResourceFile);
        }
    
        <div>@text</div>