globalization/internationalization support in .net

man068
man068 used Ask the Experts™
on
Hi,

We have our own appserver where we have implemented the internalization by having multiple properties files for different languages. Eg., For english there is a file with
say
label = label1.
For this there is a french property file with
label = defddd.

We need to port such property files into our .net framework. Are there any tools which does this. How does the globalization/internationalization in .net work. I asked about a porting tool because I have feeling that .net uses xml files for this support. Please also post any links/articles that you know of about this topic.

your help is greatly appreciated.
thanks
 
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
In .NET you will use resources files.  These can be as you pointed out XML, but you can also use a text file.

First this is a very long topic. I doubth that I can discuss every aspect in this response.  Check on the MSDN KNOWLEDGE BASE under resources or satelite assemblies, or maybe globalization.

1.  Take a text file with the following sintax:
; Comments have a semicolon on the first column
; You can place section headers in brackets as seen next
[Headers]
; These are usefull if your resource file is very long
; and you want to subdivide it.
; The values use will be place in key = value pairs  same
; as you have now.  One detail, you place a period on the
; samples.  I supposse that you want that period to be the
; string.
variable_name = language specific phrase

From the command prompt (yeah your heard rigth, command promp) use the Resgen command as such

Move to the directory where you put the txt file.  Which should be same as the one for  your application and enter

   resgen ResourceFileName.en-Eu.txt

This would create a file on that same directory with the
name:
   ResourceFileName.en-EU.resource

The en-EU part indicates language (english) and specific region of world United States. There is a very long list of posible codes to use.

On your program use a logic similar to this:

   Dim objRM as ResourceManager
   objRM = ResourceManager.CreateFileBaseResourceManager("ResourceFileName.en-EU", Server.Mappath("."), Nothing)

   ' Now where you want to use the contents of the resource file
   lblGreeting.text = objRM.GetString("variable_name")

   ' When you are finished with it discard the resource manager.  Why doing it this way instead of using = nothing, beats me.  That's the way it appears on my book.

   objRM.ReleaseAllResources

Hope this works.  By the way I have never use this.  I just show you parts of the book that I have.

Author

Commented:
thanks... a lot for the response...

which book did you refer to..? and do you have any online resources that you referred to...

thanks

Commented:
The book if Visual Basic .NET Web Applications /
  Study guide for exam 70-305)  ISBN 0-07-212580-2.  At Amazon I got it at $34.00 new.

The chapters I reffered in particular are chapter 3 and 4.
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

Author

Commented:
I have not worked on the microsoft technology before but
I heard that The resource files also should contain the location of the label in the UI. How does this resgen.exe generate this information.

thanks

Commented:
The resgen contains the name of the label.  For example You want to place a greetings in French.  Then int the french version of the resource file your write:

Greeting = Bonjour

On the English version you write

Greeting = Hello

On the Web page you will use the folowing line

lblGreeting.text = objRM.GetString("Gretting").  The part missing from my explanation is how the sistem will know how to use the french or the english version.  In the sample I gave you I explicitly asked for the English version.  Tomorrow I'll show you how to specify the language acording to the preferences of the client.  At this moment is a little late for me.
Zlatin ZlatevSenior Technical Architect, Salesforce Commerce Cloud

Commented:
@man068,
Note that in ASP.NET WebForms you can databound every property rendered by the client, so that another option is to have internalization strings in a database.

HTH

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial