Question

Actually this is a double question,

1

I'm trying to get the right variation from the following code:

SPUtility.GetLocalizedString("$Resources:MyDefaultResourceFileName,MyWantedValueKey", "MyDefaultResourceFileName", SpContext.CurrentWeb.Language)

like that I'm always getting the value from the default resource file, but if I change the language on the SPWeb, for instance en-en, I'm not getting the key value from the MyDefaultResourceFileName.en-en.resx

solution: follow this link and use this code for retrieve the values from right resource file:

SPUtility.GetLocalizedString("$Resources:MyWantedValueKey", "MyDefaultResourceFileName", (uint)Thread.CurrentThread.CurrentUICulture.LCID)

but if is deployed as AppGlobalResource, check this link and use:

HttpContext.GetGlobalResourceObject("MyResourceFile", "MyKey")

2

And the second one more simple, how I get those same values in .aspx files?

solution: helpful link

<%$Resources:FileName,Key%>

spregards!

Était-ce utile?

La solution

SpContext.CurrentWeb.Language always returns languages that is used for site creation, if you would like to change languages on your site dynamically you should use `Thread.CurrentCulture.LCID'.

If you would like to get this values in .aspx file, you should create module that deploys resources files to the GlobalResources folder. See this post how to do it.

Then in you markup you can use <%$Resources:FileName,Key%> in server tag controls.

Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange
scroll top