problem with Multi language application

jothis

Active Member
Licensed User
Hai all,

i have three language files
1)english.ini
2)Japanese.ini
3)french.ini

contents of this file is ;-

welcometxt=Welcome
exittxt=Exit
usernametxt=Username
passwordtxt=Password

each ini file has their translations.

i have a array

textarray()=Array("welcometxt","exittxt","usernametxt","passwordtxt")

My question is how can we read this text translations assigned in text files?

Please Help me?
:sign0085:
 

DouglasNYoung

Active Member
Licensed User
Longtime User
Not the most efficient code, but easy to understand. Just call read_cfg() with the name of the appropriate language i.e. read_cfg("french")

Sub read_cfg( lang as string )
Dim List1 As List
Dim thisline, thiskey, thisval As String
Dim epos As Int
Dim reader As TextReader

If File.Exists(File.DirDefaultExternal, lang & ".ini") Then
reader.Initialize(File.OpenInput(File.DirDefaultExternal, lang & ".ini"))
If reader.IsInitialized Then
List1 = reader.ReadList
For i = 0 To List1.Size - 1
thisline = List1.Get(i)
epos = thisline.indexof("=")
thiskey = thisline.SubString2(0,epos)
thisval = thisline.SubString2(epos+1, thisline.Length)
Select thiskey
Case "welcometext"
array(0) = thisval
Case "exittext"
array(1) = thisval
Case "usernametext"
array(2) = thisval
Case "passwordtext"
array(3) = thisval
End Select
Next
reader.Close
End If
Else
ToastMessageShow("Language file " & lang & "ini not found!", False)
End If
End Sub

Hope this helps....
 

Cableguy

Expert
Licensed User
Longtime User
Why not use the AhLocale Dll? it makes these tasks much easier and almost code-transparent...
 

jothis

Active Member
Licensed User
DouglasNYoung
Thanks for helping me

Not the most efficient code, but easy to understand. Just call read_cfg() with the name of the appropriate language i.e. read_cfg("french")

Sub read_cfg( lang as string )
Dim List1 As List
Dim thisline, thiskey, thisval As String
Dim epos As Int
Dim reader As TextReader

If File.Exists(File.DirDefaultExternal, lang & ".ini") Then
reader.Initialize(File.OpenInput(File.DirDefaultExternal, lang & ".ini"))
If reader.IsInitialized Then
List1 = reader.ReadList
For i = 0 To List1.Size - 1
thisline = List1.Get(i)
epos = thisline.indexof("=")
thiskey = thisline.SubString2(0,epos)
thisval = thisline.SubString2(epos+1, thisline.Length)
Select thiskey
Case "welcometext"
array(0) = thisval
Case "exittext"
array(1) = thisval
Case "usernametext"
array(2) = thisval
Case "passwordtext"
array(3) = thisval
End Select
Next
reader.Close
End If
Else
ToastMessageShow("Language file " & lang & "ini not found!", False)
End If
End Sub

Which Dll file you used to do this?
 

Cableguy

Expert
Licensed User
Longtime User
In the additional libraries section....
 
Top