> I am trying to create a multilingual application named Language. I have
> created resource files (string.<culture>.resources) from string.txt
using
> ResGen, for three cultures, and used the Assembly Linker to put them
into
> satellite assemblies, creating Language.Resources.dll in the
corresponding
> subfolders in the bin folder (de, fr and de-AT).
>
> Could any one tell me :
>
> When I create the main assembly, is the 'fallback' resource file
compiled
> into the main dll. I assume that it is, but I am wondering whether I
need
> to create a Language.Resources.dll file using AL.exe to go in the bin
> folder for my main asssembly.
>
> I am using the following code to try and access the resources. I keep
> getting this message :
>
> Could not find any resources appropriate for your culture or the neutral
> culture in your assembly. baseName: Language.string locationInfo: <null>
> resource file name: Language.string.resources assembly: _pphfhpq,
> Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
>
> It seems to be looking for locationInfo - why is it null and how does it
> get a value?
>
> Which folder should my neutral culture resources file be in when I build
> the application?
>
> I am a new programmer and there's a lot of stuff I don't know about
> assemblies etc. If any one can help me I'd be very grateful. Am I
using
> the Resource Manager correctly to look in the resource
> file "string.resources". For this example I have hard coded in the
> current culture I want to use.
>
> Dim Resources As ResourceManager
>
> CurrentCulture = "de-DE"
> Thread.CurrentThread.CurrentCulture() = New CultureInfo
> (CurrentCulture)
> Resources = New ResourceManager("string", Me.GetType
> ().Assembly)
> Me.Button1.Text = Resources.GetString("txtSearch")
> Me.Button2.Text = Resources.GetString("txtWelcome")
>
I could make it work for standard english (en) and french (fr). I did the
following:
1. create 2 assembly resource files in your project (File->Add New Item...
Assembly Resource Files). For example strings.resx and strings.fr.resx
2. fill the resource files by using the editor of Visual Studio.NET
3. build the solution. VS.NET will create one satellite assembly for the
french resources under the bin directory of your project
(bin/fr/projectName.resources.dll). English resources are contained in the
main dll of your project (bin/projectName.dll).
4. then edit you global.asax.vb file:
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
Try
Thread.CurrentThread.CurrentCulture =
CultureInfo.CreateSpecificCulture(Request.UserLanguages(0))
Catch
Thread.CurrentThread.CurrentCulture = new CultureInfo("en")
End Try
Thread.CurrentThread.CurrentUICulture =
Thread.CurrentThread.CurrentCulture
Application("RM") = New ResourceManager("projectName.strings",
Me.GetType().Assembly.GetExecutingAssembly)
End Sub
5. To get a string identified by "home_welcomeLabel) from the resources:
...
Protected WithEvents home_welcomeLabel As
System.Web.UI.WebControls.Label
...
Dim rm as ResourceManager
rm = Application("RM")
home_welcomeLabel.Text = rm.GetString("home_welcomeLabel")
I hope it will help. If you change your language from Internet Explorer,
you should get the right resource in the language you choose. I also
suggest that you use a program named Reflector to see the content of your
main dll.