Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resources for strings

Status
Not open for further replies.

Ladyhawk

Programmer
Jan 22, 2002
534
AU
I understand how to create different language resource files for user interface components, but I can't figure out how to create them for strings in the code. For example, for messageboxes etc.

Can anyone enlighten me, please?

Ladyhawk. [idea]
** ASP/VB/Java Programmer **
 
Use the .getstring method of the ResourceManager (as you for the controls I guess ... ?).

-----------------------------
Dim r As New System.Resources.ResourceManager("MySolution.MyResourcefile", System.Reflection.Assembly.GetExecutingAssembly)
Messagebox.Show(r.GetString("TestString1"))
-----------------------------

Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
I take it you have set the interface culture using threading, and you want to retrieve the string for the language.

Steps:

1. Declare a resource manager in the load event.

2. make a sub procedure:

e.g

Private sub Initialise_Strings
me.button1.text = rm.GetString("OPEN")
me.button2.text = rm.GetString("CLOSE")
me.button3.text = rm.GetString("NEXT")
me.lblCulture.text = Thread.CurrentThread.CurrentUIculture
End Sub

3. When the culture is changed, you can can simply Initialise_Strings to change all the strings you want again.

To do this, you need to download the resource manager for VB.NET. You then need to create the text files using the resource editor, then create the satellite dlls. If you have three languages, for example en-US, de-DE, ar-AE, these will all have their own directory in the /bin directory of the project. You save the text files there, then compile the satellite dlls from the vb.net command line environment.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top