I'm new to VB.net and I'm trying to do a simple multilingual project.
So far I've created 2 resource files:
en-US.resx
pt-PT.resx
in both of them I have the same ID's and diferent values (strings only) (these strings will be used across multiple forms)
When I change the laguage I do:
Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US")
or
Thread.CurrentThread.CurrentCulture = New CultureInfo("pt-PT")
Based on the language I want to see.
But I dont know how to access my resource files properly, Doing:
Dim assembly As System.Reflection.Assembly
assembly = Me.GetType.Assembly
Dim resourceManager As New System.Resources.ResourceManager("My.Resources", assembly)
MsgBox(resourceManager.GetString("TEST"))
Gives me an exception System.Resources.MissingManifestResourceException' occurred in mscorlib.dll
What am I missing?
edit after the first sugestion:
Well I just stop using the resource manager. Apparently the resource manager is not needed and now its working. I hope this helps someone else when the tutorials seem to fail :\
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US")
MsgBox(My.Resources.MStrings.TEST)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("pt-PT")
MsgBox(My.Resources.MStrings.TEST)
End Sub
End Class