Solved

Localization in VB.net

Posted on 2004-10-13
6
6,414 Views
Last Modified: 2010-04-21
I need to write a winforms app that is going to be distributed in 3 languages,
so ALL the text in my app should be in those 3 languages. What is the best way to approach this.

Somehow I would like one solution that I want to build in either of the 3 languages
0
Comment
Question by:RonaldBiemans
6 Comments
 
LVL 7

Expert Comment

by:J_Mak
ID: 12295647
It would all begin with Inheritnace.... each form that you create with one language must have similar charateristics with those in another language. So the best way to start off is to create forms that have common properties with all 3 languages. The customised forms for a certain language then inherit from the parent form and change it as it sees fit. Have constants for all 3 so that when you build (like for labels, text boxes, etc), it can choose from either. It is much more complicated than this, but this would be a start.
0
 
LVL 6

Accepted Solution

by:
etmendz earned 200 total points
ID: 12295802
I have two ways in mind:

1) You can use resources which is inherent to .Net since v1.0. Easiest to maintain and deploy. Read more from the following articles:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpqstart/html/cpsmpnetsamples-howtoresources.asp
http://samples.gotdotnet.com/quickstart/aspplus/default.aspx?url=%2fquickstart%2fhowto%2fdoc%2fuseresources.aspx
http://www.c-sharpcorner.com/Code/2004/Jan/GloblizationInDotNEt.asp

2) You can also use a database that supports unicode data. Then use the database to store a list of keys and translated values. On application startup or when the language setting is changed, you can (re)load the labels/messages to a global collection/dictionary. Note that there are some memory overhead here...

Choose the approach you are comfortable with.

Have fun...
0
 
LVL 18

Assisted Solution

by:armoghan
armoghan earned 200 total points
ID: 12295845
I dont get it exectly. It seems simple.

why dont you just make the Localizable property of the Forms true and Language = XYZ for different forms and make different Resx file, they will be kept in different DLLs so that they can be loaded when the language is changed.
If you want to chnage the language at runtime,
Instead of insitalizing all the components in initilizeComponents make a custom method which takes language as an argument, So when you, lets say, chnage the language from the menu, a listener will be attached to all the forms and that it called and they initialzie the components again in different languages,

0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 14

Assisted Solution

by:ptakja
ptakja earned 100 total points
ID: 12296655
armoghan is right, (and that is the best way to go) but that only covers the form UI elements. There are still error messages, text displayed in message boxes, status bar messages, etc...for that you would need to add a resource file (one for each language) that has key/value pairs in it.

In your code you create an instance of a ResourceManager object which gives you access to the resource file.

By default, your app will attempt to run under the language Windows is running in. If you don't have resources for that language (and you haven't set up your forms to run in that language (as armoghan suggests)) you need to provide a fallback to some default language.

The book "Programming Microsoft Visual Basic .NET" by Franceso Balena has an excellent chapter on localization and the new things that came with .NET to make this much simpler than it used to be with VB6.

Good luck!
0
 
LVL 18

Expert Comment

by:armoghan
ID: 12319161
Thanx.
Glad to help the person on number 1 :)
0
 
LVL 7

Expert Comment

by:Inteqam
ID: 31365748
what about lookup tables? or should i also use resources?
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question