Hi all,
i was created multilanguage app loading text from xml file. All working but i have 2 problems, im having hard time to get special characters(as diff langs has) works and also troubles with groupbox elements. please can u fill up my code about what i missing?
Here is my code to pharse xml:
Thx youCode:Public Shared Sub load_lang(ByVal path As String, ByVal frm As Form) If Not File.Exists(path) Then Exit Sub End If [GLOBAL].lang = path Dim xname As String = "", attr As String = "", form As String = "" Dim ren As Boolean = True Dim reader As New XmlTextReader(path) MESG.clear() Try While ren ren = reader.Read() Select Case reader.NodeType Case XmlNodeType.Text If xname = "msgbox" Then MESG.add_mesg(DirectCast(reader.Value, String)) End If If xname = "form" OrElse form <> frm.Name Then Exit Select End If If attr.Length > 0 Then Dim elms As String() = xname.Split("."c) Select Case attr Case "menu" Dim tsmi As ToolStripMenuItem Dim ms As MenuStrip = DirectCast(frm.Controls(elms(0)), MenuStrip) tsmi = DirectCast(ms.Items(elms(1)), ToolStripMenuItem) For k As Integer = 2 To elms.Length - 1 tsmi = DirectCast(tsmi.DropDownItems(elms(k)), ToolStripMenuItem) Next tsmi.Text = DirectCast(reader.Value, String) Exit Select Case "bar" Dim ts As ToolStrip = DirectCast(frm.Controls(elms(0)), ToolStrip) ts.Items(elms(1)).Text = reader.Value Exit Select End Select Else If xname <> "msgbox" Then frm.Controls(xname).Text = DirectCast(reader.Value, String) End If End If Exit Select Case XmlNodeType.Element xname = reader.Name If xname = "form" Then form = reader.GetAttribute("name") Else If reader.HasAttributes Then attr = reader.GetAttribute("type") Else attr = "" End If End If Exit Select End Select End While Catch ex As Exception ReadErrorMessage(37, "load_lang - clsLanguage", ex.Message, ex.StackTrace) ' MessageBox.Show(e.Message) 'MessageBox.Show(MESG.get_mesg(MSGBOX.message_lang), "Error", MessageBoxButtons.OK, MessageBoxIcon.[Error]) End Try reader.Close() End Sub


Reply With Quote