Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Plenty of links, no definitive answer found. How to use localizable resource files and change the current locale for a user under sharepoint AND external apps.

I have global resources deployed with my solution. The default invariant file works absolutely fine, but when I set the user's locale to something different, the locale is not being picked up.

Do we need satelite assemblies? I see VS2010 is creating folders and dlls under the bin directory one for each culture variant - but with the same name!? So this post is erroneous as u cant add the same dll name to the package.

I would like to be able to load the resources from the dll so that other apps (services/consoles) can also access these resources.

Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("zh-HK");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("zh-HK");
object o = HttpContext.GetGlobalResourceObject("myAppResources", "FRONT_PAGE_INTRO");

This is what VS2010 has in the manifest:

 <ApplicationResourceFiles>
    <App_GlobalResourceFile Location="myApp\myAppResources.resx" />
    <App_GlobalResourceFile Location="myApp\myAppResources.zh-HK.resx" />
  </ApplicationResourceFiles>

and

<Assembly Location="myApp.resources.dll" DeploymentTarget="GlobalAssemblyCache" />
share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

Turned out to be where I was registering the locale, this needs to be in the PreRequestHandler not the BeginRequest one.

application.PreRequestHandlerExecute += SetLocale;

not

application.BeginRequest += SetLocale;

private void SetLocale(object sender, EventArgs e)
{
   LocalizationHelper.SetThreadCurrentCulture();
}

Obvious!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.