I've approached this problem differently. I've added two resource files (1
for English, 1 for French) with the Build Action set to Embedded Resource.
This becomes a strongly type resource class (in this case a class called
StringTable.. actually StringTable.fr.resx and StringTable.resx). Now you
just need to do this. Set you culture then make a call like this to get the
title in the current culture.
MyAssembly.StringTable.MyTitle
Hope this helps,
Michael Klingensmith
http://www.seeknsnatch.com [quoted text, click to view] <Eniac0@gmail.com> wrote in message
news:1152203066.998590.182250@s26g2000cwa.googlegroups.com...
> Hello guys, I have a (small?) problem with resource files ever since I
> switched to .net 2005.
>
> in vs.net 2003, generally, i would handle resource files like so :
>
> in the page_load event, I detect the selected language in session, then
> I do a small if-then-else to select the appropriate resource file. then
> I finally create a new ResourceManager based on the assembly name, file
> name and language.
>
> In vs.net 2005, I cannot load myself the resource files because I dont
> know how to set the project's assembly name. so i create my
> ResourceManager with something like :
> objRM = New ResourceManager("myassembly.languages",
> Assembly.GetExecutingAssembly())
>
> The reason why I do it like this is that generally, in our apps, we
> have a "French" or "English" button at the top of our pages, to let the
> user switch languages at will. So i need a way to detect that change
> and instruct .net to load a different resource file.
>
> How would I be able to do this in Visual Studio.net 2005 ?
>
> ----------------------------
> in vs.net 2003 it would look somewhat like this :
> (note that this is all typed on the top of my head, there could be a
> few mistakes)
>
> private sub page_load
> dim strQuerystringLang as string = Request.Querystring("lang")
> dim intLang as integer = 1
> dim objRM as ResourceManager
>
> if Not (strQuerystringLang is nothing) andalso
> isnumeric(strQuerystringLang) then
> intLang = ctype(strQuerystringLang, integer)
> else
> intLang = Ctype(Session("Language"), integer)
> end if
>
> if intLang = 2 then
> Thread.CurrentThread.CurrentUICulture = New CultureInfo("en-CA")
> Thread.CurrentThread.CurrentCulture =
> CultureInfo.CreateSpecificCulture("en-CA")
> else
> intLang = 1
> Thread.CurrentThread.CurrentUICulture = New CultureInfo("fr-CA")
> Thread.CurrentThread.CurrentCulture =
> CultureInfo.CreateSpecificCulture("fr-CA")
> end sub
>
> Session("Language") = intLang
> objRM = New ResourceManager("myassembly.languages",
> Assembly.GetExecutingAssembly())
>
> SetLabels() 'Uses objRM to manually set all labels on the page
>