Ich will da demnächst auch mal ein Tutorial drüber machen, weiss aber nicht, wann ich dazu komme.
Sub ReadLanguageText(Language, Section, Key, Macro, Default) As String
Dim Item As String
Dim pos1 As Int
Dim pos2 As Int
Dim Blanks As Int
Dim li As String
Dim re As String
Item = ""
If File.Exists(cLngPath, Language) = True Then
Item = ReadLanguageFile(cLngPath, Language, Section, Key, Default)
If Item.IndexOf("<LF>") > -1 Then
Do While Item.IndexOf("<LF>") > -1
Item = Item.Replace("<LF>", CRLF)
Loop
End If
If Macro.Length > 0 AND Item.IndexOf("<DATA>") > -1 Then
Item = Item.Replace("<DATA>", Macro)
End If
pos1 = Item.IndexOf("#")
pos2 = Item.IndexOf2("#", pos1 + 1)
If pos1 > -1 AND pos2 > -1 Then
li = Item.SubString2(0, pos1)
re = item.SubString(pos2 + 1)
Blanks = Item.SubString2(pos1 + 1, pos2)
For i = 0 To Blanks
re = " " & re
Next
Item = li & re
End If
Else
Item = "?"
End If
Return Item
End Sub
Sub Replace(text As String, search As String, exchange As String) As String
Dim Item As String
Item = ""
If text.IndexOf(search) > -1 Then
Do While text.IndexOf(search) > -1
Item = text.Replace(search, exchange)
Loop
End If
Return Item
End Sub
Sub ReadLanguageFile(directory As String, fileINI As String, session As String, key As String, default As String)
Dim value As String
Dim rSECTION As String
Dim flgSESSION As Boolean
Dim rKEY As String
Dim flgKey As Boolean
Dim rdTEXT As TextReader
Dim p As Int
Dim k As String
LastError = ""
value = default
If File.Exists(directory, fileINI) = True Then
rSECTION = ""
flgSESSION = False
flgKEY = False
rKEY = ""
rdTEXT.Initialize2(File.OpenInput(directory, fileINI), "ISO-8859-1")
rSECTION = rdTEXT.ReadLine.Trim
Do While rSECTION <> Null
If (rSECTION <> "") AND (rSECTION.CharAt(0) <> ";") Then
If rSECTION.CompareTo("[" & session & "]") = 0 Then
flgSESSION = True
rKEY = rdTEXT.ReadLine
Do While rKEY <> Null
If rKEY <> "" Then
p = rKEY.IndexOf("=")
If p > -1 Then
If rKEY.SubString2(0, 0) <> "[" Then
k = rKEY.SubString2(0, p)
If key.CompareTo(k) = 0 Then
flgKEY = True
value = rKEY.SubString(p + 1)
Exit
End If
End If
End If
End If
rKEY = rdTEXT.ReadLine
Loop
End If
End If
If flgSESSION = True Then
Exit
Else
rSECTION = rdTEXT.ReadLine
End If
Loop
rdTEXT.Close
If flgSESSION = False Then
LastError = "SectionFoundError"
Else If flgKEY = False Then
LastError = "KeyFoundError"
End If
Else
LastError = "FileNotFoundError"
End If
Return value
End Sub
ProgressDialogShow(Global.ReadLanguageText(Global.cLangFile, "Main", "10", "", ""))
; esdaS©'s ApplicationFavorites for Android
; (c) 08/2011 Copyright and all rights reserved by:
; esdaS© ESPRIT DATA SOFTWARE Bodo-Norbert Göldner
;
; This is the language file that accompanies
; esdaS©'s ApplicationFavorites for Android
;
; If you want to translate this language file into your own language,
; which is very easy, you should take care of the following:
;
; 1. Only translate the parts of the language file that are
; preceeded by an '=' sign. So, do not translate the line
; "[section]", for example!
;
; 2. This language file makes use of special control characters, which
; you are not allowed to change. The following control characters
; are distinguished:
;
; <DATA> - a string will be inserted at this place at runtime
; <LF> - a Carige Return will be inserted at this place at runtime
; #10# - many Carige Return will be inserted at this place at runtime with blanks 10=number
[Programm]
ProgramName=esdaS©'s ApplicationFavorites for Android
Language=Deutsch
LastDate=31.10.2011
Version=1.00.9
[Main]
10=Installierte Apps werden ermittelt<LF>#1#und Favoritenliste wird gelesen!
20=alle Apps
30=Favoriten
40=Über...
50=Copyright und alle Rechte reserviert bei:
60=Lizenziert für:
70=unregistriert Kopie
80=IMEI-Nr.: <DATA>
90=freischalten
100=Applikation <DATA> wird zur Favoritenliste zugefügt.
110=Applikation <DATA> wird von der Favoritenliste gelöscht.
\data\data\<Package-Name>\language
'Code module
'Subs in this code module will be accessible from all modules.
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim locale As AHLocale
Dim strJa,strNein,strExit As String
End Sub
Sub InitLanguage
locale.Initialize
'Log("Sprache=" & locale.Language)
Select Case locale.Language
Case "de"
strJa="Ja"
strNein="Nein"
strExit="Beenden"
Case "it"
strJa="Sì"
strNein="No"
strExit="Esci"
Case "fr"
strJa="Oui"
strNein="No"
strExit="Sortir"
Case Else
strJa="Yes"
strNein="No"
strExit="Exit"
End Select
End Sub
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("frmMain")
'Init Language-Modul
mLanguage.InitLanguage
Test
End Sub
Sub Test
Msgbox2("Test","Test 1",mLanguage.strJa,mLanguage.strNein,"",Null)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Dim PText As List
.
.
Sub LoadProgTexts
PText = File.ReadList(File.DirRootExternal, "gps.txt")
End Sub
.
.
MsgBox(PText.Get(10), PText.Get(11))
IMEI-Nr.: <DATA>
IMEI-Nr.: 123456789012345