'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 Sprog As Map
End Sub
Sub File_init(Lf As String)
Sprog.Initialize
If File.Exists(File.DirAssets, Lf) Then
Sprog = File.ReadMap(File.DirAssets,Lf)
Else
Log("Language file : " & Lf & " missing.")
End If
End Sub
'
' If there isnt any Translation the original is keept
'
Sub ObjTo(v As View)
If v Is Label Then
Dim l As Label
l = v
If Sprog.ContainsKey(l.Tag) Then l.Text = Sprog.Get(l.Tag)
End If
End Sub
Sub ThisPanel(v As View)
Dim p As Panel
p = v
If p.NumberOfViews > 0 Then
For i = 0 To p.NumberOfViews-1
If p.GetView(i) Is Panel Then
Log(p.GetView(i))
ThisPanel(p.GetView(i))
Else
ObjTo(p.GetView(i))
End If
Next
End If
End Sub
Sub ThisActivity(P As Page)
If P.RootPanel.NumberOfViews > 0 Then
For i = 0 To P.RootPanel.NumberOfViews-1
If P.RootPanel.GetView(i) Is Panel Then
ThisPanel(P.RootPanel.GetView(i))
Else
ObjTo(P.RootPanel.GetView(i))
End If
Next
End If
End Sub
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim mpLang As Map
Dim Language As String
End Sub
Sub InitLanguage
Dim Lang As String
Dim lst As List
Dim str() As String
Dim tmp As String
mpLang.Initialize
Log("Sprache=" & GetPreferredLanguage)
Select Case GetPreferredLanguage
Case "de"
Language = "de_"
Lang="lang_de.txt"
Case "it"
Language = "it_"
Lang="lang_it.txt"
Case Else
Language = "en_"
Lang="lang_en.txt"
End Select
lst=File.ReadList(File.DirAssets, Lang)
For i = 0 To lst.Size - 1
tmp = lst.Get(i)
str = Regex.Split("=", tmp)
If str.Length = 2 Then
mpLang.Put(str(0),str(1))
Else If str.Length > 2 Then
mpLang.Put(str(0), tmp.SubString(tmp.IndexOf("=") + 1))
End If
Next
End Sub
Sub getStr(Key As String) As String
Dim ret As StringBuilder
ret.Initialize
Dim str() As String=Regex.Split("\\n\ ", mpLang.Get(Key))
For i = 0 To str.Length - 1
ret.Append(str(i))
If i < str.Length - 1 Then ret.Append(CRLF)
Next
' Log("Key= " & Key & " ;" & ret.ToString)
Return ret.ToString
End Sub
'NSString * myString = [[NSLocale preferredlanguage]objectAtIndex:0];
Sub GetPreferredLanguage As String
Dim no As NativeObject
Return no.Initialize("NSLocale") _
.RunMethod("preferredLanguages", Null).RunMethod("objectAtIndex:", Array(0)).AsString
End Sub
[de]
strJa=Ja
strNein=Nein
[en]
strJa=Yes
strNein=No
[it]
strJa=Sì
strNein=No
Can you upload a test file?Hi Fillipo,
How are you dealing with non UTF char.
Here in Denmark we have ÆØÅ
The code module break Down trying to load them
Mogens