Click here to Skip to main content
Click here to Skip to main content
Go to top

LANGUAGE SELECT for your programs

, 1 May 2004
Rate this:
Please Sign up or sign in to vote.
Make its application international!
<!-- Article Starts - DO NOT ADD HTML/BODY START TAGS--><!-- Download Links --> <!-- Add the rest of your HTML here -->

Introduction

LANGUAGE SELECT for your programs

language screenshot

German, English, French, Spanish

Make its application international!

In a simple way

With only 3 functions and four resource files

The Functionen is pure Visual basic Net code version the Functionen is pure Visual basic Net code version 2003

function 1

Imports System

Imports System.IO

Imports System.Collections

Imports System.Resources

Imports System.Globalization

Imports System.Threading

Module ptLanguage

#Region "Strings aus der ResourceDatei holen"

Public Function ResString(ByVal rIndex As String, ByVal LgManuel As String) As String

'

On Error GoTo ErrorHandler

'

Dim lang As CultureInfo = Thread.CurrentThread.CurrentCulture

Dim spr As String = Trim(lang.ToString())

Dim spr_file As String

Dim SuchStr As String

Dim ret As String

Dim lgPfad As String = CurDir()

'

ret = "Error"

'

If Trim(LgManuel) <> "" Then

spr = Trim(LgManuel)

End If

'

Select Case spr

Case Is = "de-DE"

spr_file = "de.resources"

Case Is = "en-US"

spr_file = "us.resources"

Case Is = "fr-FR"

spr_file = "fr.resources"

Case Is = "es-ES"

spr_file = "es.resources"

Case Else

spr_file = "us.resources"

End Select

lgPfad = lgPfad & "\" & spr_file

If File.Exists(lgPfad) Then

Dim rr As ResourceReader = New ResourceReader(lgPfad)

Dim rlg As IDictionaryEnumerator = rr.GetEnumerator

While rlg.MoveNext()

SuchStr = CType(rlg.Key, String)

If Trim(SuchStr) = Trim(rIndex) Then

ret = CType(rlg.Value, String)

Exit While

End If

End While

rr.Close()

ResString = ret

End If

Exit Function

ErrorHandler:

ret = "Error"

Exit Function

'

End Function

#End Region

#Region "Language Ini vom System"

'

Public Sub Language_Ini()

'

Dim lang As CultureInfo = Thread.CurrentThread.CurrentCulture

Dim spr As String = Trim(lang.ToString())

'

Select Case spr

Case Is = "de-DE"

Select_Language = CDe

Case Is = "en-US"

Select_Language = CUs

Case Is = "fr-FR"

Select_Language = CFr

Case Is = "es-ES"

Select_Language = CEs

Case Else

Select_Language = CUs

End Select

'

End Sub

'

#End Region

End Module

function 2

Private Sub Language_FrmMain(ByVal sLanguage As String)

'

Me.Text = ResString("1", sLanguage)

Me.TbGerman.Text = ResString("100", sLanguage)

Me.TbUs.Text = ResString("101", sLanguage)

Me.TbFr.Text = ResString("102", sLanguage)

Me.TbEs.Text = ResString("103", sLanguage)

Me.Lbl1.Text = ResString("104", sLanguage)

Me.Lbl2.Text = ResString("105", sLanguage)

Me.Lbl3.Text = ResString("106", sLanguage)

Me.Lbl4.Text = ResString("107", sLanguage)

Me.Lbl5.Text = ResString("108", sLanguage)

Me.BtnExit.Text = ResString("109", sLanguage)

'

End Sub

mopre see source code

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

ptnewmedia
Web Developer
Germany Germany
program developer since 1976
programming languages visual C++ and
visual basic DOT Net.
I live and work six months in Germany and six months in Florida daytona
homepage
http://www.sidedc.com/
and
http://www.sidedc.com/
and
http://spider.sidedc.net/

Comments and Discussions

 
GeneralProblem while downloading File Pinmembereg_Anubhava26-Jun-09 22:07 
Generalproblem while downloading Pinmemberarunmanoj10-Apr-05 0:08 
QuestionWhy oh why? PinmemberRay Hayes2-May-04 3:54 
Why is it that us "English" people need to always accept "US" as the description for our own language?
 
Your map shows the USA not England (or UK) for English...
 
It's not just this article, I've lost touch of the number of times I have a choice between:
 
US English
German
French
 
But no "UK"... even when I do select "English", it's often American English with its different spelling, grammar and phrases.
 
If you're going to show a country, the British Isles is the correct country shape for English!
 
If you're going to show a flag... the Union Jack will do...
 
If needed, also show the US flag/country shape, but don't make us English have to select the wrong country.
 
Regards,
Ray
AnswerRe: Why oh why? PinmembertheJazzyBrain2-May-04 22:22 
QuestionSubmission guideline !? PinmemberJochen Kalmbach2-May-04 2:27 
AnswerRe: Submission guideline !? Pinmemberlordofscripts29-Oct-04 2:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 2 May 2004
Article Copyright 2004 by ptnewmedia
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid