Last post Aug 11, 2008 09:14 AM by learnerplates
Aug 07, 2008 05:32 PM|learnerplates|LINK
I have a web app running with ASP.NET but for reasons I cannot use the ASP.NET localisation mechanism directly, instead I have to use .NET localisation indirectly.
How can I call the Localistion mechanism?
The runtime will be calling my own static method which returns the correct string based on a Culture supplied at runtime. It's this method that I want to extract the correct string from a resx file. This resx file will live on the web app but I'm not sure
where or how it will stored for multiple cultures, what's the best approach?
I've tried to use the ResourceManager to call a Resource that's in a dll but I'm not sure exactly how to use this for a web app or if it is what I should be using, is it?
Can I use the Global type which places the resx files in the App_Global ? how can I invoke this?
If I use the ResourceManager how do I new it up? do I need a different dll for each Culture with a different name?
Aug 07, 2008 11:50 PM|eric zhou|LINK
I think you should check this link first
Aug 08, 2008 10:27 AM|learnerplates|LINK
It's of no use to me, I'm not using the ASP.NET mechanism I'm using it through the System.Resources.ResourceManager class and am pulling my hair out.
There's lots of documentation but it doesn't tell you how to use it, maybe someone here can help.
I managed to get the localization to work with the bare .resource files (It took me the whole morning to figure out that I need to use a tool to create these!),
ResourceManager _rm = ResourceManager.CreateFileBasedResourceManager("strings",Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "Resources" ), null);
but I've read that there can be problems with these with file locking so I'm trying to use a similar mechanism but with the .resource file in a dll, Satellite DLL, described here http://msdn.microsoft.com/en-us/library/21a15yht(VS.71).aspx
But it doesn't work with the DLLs, I have the dlls in the locations mentioned in the above link and have created them with the Resgen.exe tool from my resource files. But I think it's the call to it that's causing the problem, I can only get the default root English resource strings to work. I think this is because the ResourceManager does not change the culture when calling the GetString see below, nightmare this thing..........
My Culture dlls are in my website in a directory <websiteroot>/Resources
public string GetResourceString(string resourceStringName, string culture)
ResourceManager _rm = new ResourceManager("strings", Assembly.LoadFile(Path.Combine( Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources"), "strings.resources.dll") ) );//Works for en only
CultureInfo cInfo = new CultureInfo(culture);
string result = _rm.GetString(resourceStringName, cInfo);
Aug 09, 2008 10:16 AM|TATWORTH|LINK
I suggest that you look at
http://www.guysmithferrier.com/ and in particular at Guy Smith's book
ISBN 0321341384. The book is available online at Safari books at
Also his presentation
Aug 11, 2008 09:14 AM|learnerplates|LINK
I found the issue, there's a little caveat with the .resources file to satellite assembly, the .resources must be named in a certain way, it must contain it's culture name e.g. for spanish the name must end with .es.resources.
With the ".es.resources" in the name it won't be picked up and the default is always used.
This cost me about a day, very very strange I've documented it here