多语言开发环境程序

Borland   C++   Builder   5.0软件开发的国际化   
在Borland   C++   Builder   5.0中提供了为应用程序定制不同语言版本的的功能,下面通过具体的例子来说明其实现过程。 
1:建立一英文般的窗口,窗口上有两按钮。(Caption= “My   Button “,Caption= “OK “)     
2:编译,链接程序。 
3:关闭程序,通过主菜单Project   |   Language   |   Add…打开Add   Languages对话框,然后按照提示信息进行,中间有一个步骤需要选择语言,如(图二)请选择你需要的语言,例如 
选中国(在中国前打标志)。选完之后,按next向下进行,中间经过编译等过程,直到出现Translation   Manager窗口。 
(图二) 

4:在Translation   Manager窗口中,展开左边的的树型控件,然后定位到Forms|Unit1上 
如图三,接着就可以在右面的窗口中修改字符的内容了。将15 (Caption= “OK “),改成“确定”;将20 (Caption= “My   Button “),改成“我的按钮”保存并关闭Translation   Manager窗口。 
图三 
6:在BCB集成环境中,保存所有修改的结果,同时将.BPG文件保存到目录中。然后编译、链接新工程。哈哈,多国语言版本完成。 

————————————————————————————

eg:


利用XML文件作的多语言DEMO程序

”””””””””””””””””””””””””””””’

” 多語系設置類

” Create: Bunny_Young 2010-03-12

” email:yangmeiwen@163.com

”””””””””””””””””””””””””””””’

” Modification history:

”””””””””””””””””””””””””””””’

Imports System.Xml

Imports System.Data

Imports System.Web

Imports System.Web.UI

Imports System.Web.UI.WebControls

Imports System.IO

Public Class MutiLanguage

Const _LANGUAGE_NAME = “language”

Const _PAGE_NAME = “pageName”

Const _CONTROL_NAME = “controlName”

Const _CONTROL_TYPE = “controlType”

Const _CONTROL_VALUE = “controlValue”

Private _PageName As String ”resource讀取路徑

Private _languageType As String ”

Private _xmlDoc As XmlDocument

Private _savePath As String

Private ds As DataSet

Sub New(ByVal strLanguage As String, ByVal aspxPage As String)

‘savePath = “~/Resource/” + strLanguage

_PageName = “~/Resource/” + strLanguage + “/” + aspxPage + “.xml”

_savePath = “~/Resource/” + strLanguage

_savePath = HttpContext.Current.Server.MapPath(_savePath)

_PageName = HttpContext.Current.Server.MapPath(_PageName)

_languageType = strLanguage

End Sub

Public Sub GetDataSet()

ds = New DataSet()

ds.ReadXml(_PageName, XmlReadMode.Auto)

End Sub

Public Function UpdateLanguage(ByVal _controlName As String, ByVal _controlType As String, ByVal _controlValue As String) As Boolean

GetDataSet()

For Each dr As DataRow In ds.Tables(0).Rows

If dr(“controlName”) = _controlName And dr(“controlType”) = _controlType Then

dr(“controlValue”) = _controlValue

End If

Next

ds.WriteXml(_PageName, XmlWriteMode.IgnoreSchema)

ds.ReadXml(_PageName)

End Function

Public Function GetControlsList() As List(Of UIControl)

GetDataSet()

Dim dt As DataTable = ds.Tables(0)

Dim ResultList As New List(Of UIControl)

For Each dr As DataRow In dt.Rows

Dim MyControl As New UIControl

MyControl.ControlName = dr(“controlName”)

MyControl.ControlType = dr(“controlType”)

MyControl.ControlValue = dr(“controlValue”)

ResultList.Add(MyControl)

Next

Return ResultList

End Function

”’

”’ 主動生成資源文件

”’

”’ 語言類別

”’ WEB PAGE

”’

Public Sub WriteResourceFile(ByVal Page As UI.Page)

Try

If Not Directory.Exists(_savePath) Then

Directory.CreateDirectory(_savePath)

End If

Dim writer As New XmlTextWriter(_PageName, Nothing)

writer.Formatting = Formatting.Indented

”語言類別

writer.WriteStartElement(_LANGUAGE_NAME, _languageType)

LoopAllControls(Page, writer)

”語言類別結束

writer.WriteEndElement()

writer.Close()

Catch ex As Exception

End Try

End Sub

Private Sub LoopAllControls(ByVal oCtrl As Control, ByVal writer As XmlWriter)

For Each _Ctrl As Control In oCtrl.Controls

Dim _strName As String = _Ctrl.GetType.Name.ToUpper

If _strName = “LABEL” Or _strName = “BUTTON” Then

Dim strValue As String

Dim strComment As String

If _strName = “LABEL” Then

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2012年9月15日
下一篇 2012年9月16日

相关推荐