Hi all,
I am developing one webapplication in asp.net with C#. This application has
to support localization. I created the complete application here in my
development environment but the localization part was done in my
HeadQuarters. The localization team can give all the supported language
resource files in the form of .resx files. All the .resx files will be saved
into separate folder which is not in my web application project metadata. I
am creating a single satelite assembly out of all the available .resx files
using ResGen.exe and AL.exe's. Resgen will create the .RESOURCE files from
the .Resx file and AL.exe will embed all the .RESOURCE files into single
satelite assembly.
In my webform code i am getting the localized string as follows.
LocRM = new ResourceManager("MyStrings.ja",
Assembly.LoadFile("C:\MyStrings.resources.dll"));
string Message = LocRM.GetString("msg");
The above code is working fine in normal conditions but it doesnot support
fallback feature. If the "MyStrings.ja" resource is not embedded in the
MyStrings.resources.dll file it should get the string from the default
resource called "MyStrings.en". The default resource is english MyStrings.en
will be always embedded in the assembly.
I am instantiating the ResourceManager class as above and the first
parameter i am passing will come dynamically from one function based on the
clients browser settings. So if the specified resource file is not available
it should get the string from default resource file. So please help me how
to do this. Providing code sample will greately helps me. Is i am doing in
correct way to support localization from the separate single satelite
assembly or is there any better way to do this?
Thanks in advance.
Srinivas Chintakindi
Marin Millar - 18 Nov 2005 18:30 GMT
I think the problem is that you are specifying the culture name when
creating your ResourceManager and you are trying to load the resource file
instead of the main assembly. This overrides the ResourceManager internal
resource loading logic. The ResourceManager will always search for the
appropriate .dll based on the culture. Try something like this:
LocRM = new ResourceManager("MyStrings", Assembly.Load("MyStrings"));
Hope this helps.
Marin Millar - 18 Nov 2005 18:32 GMT
I should also mention that ASP 2.0 now has better localization support, so
that you don't need to create your own ResourceManager. Take a look at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html
/ASP2local.asp