Click here to Skip to main content
15,891,423 members
Articles / Programming Languages / Visual Basic

LANGUAGE SELECT for your programs

Rate me:
Please Sign up or sign in to vote.
1.00/5 (13 votes)
1 May 20042 min read 43.7K   11  
Make its application international!
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

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

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


Written By
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