VBScript国际化指南/最佳实践

时间:2011-09-07 07:41:00

标签: internationalization vbscript

和平在你们身上!

我一直致力于国际化,我想要VBScript指南。 Java和JavaScript有很多材料,但经过对VBS的广泛研究后,除了格式,格式等等一些函数的位和部分之外,我找不到任何东西,也没有最佳实践/指南。

我该怎么办?

1 个答案:

答案 0 :(得分:1)

其中一个重要的事情是使用已存在的内容,例如,您可以使用GetLocaleInfo API。

像这样的代码:

' Return a piece of locale information.
Private Function LocaleInfo(ByVal locale As Long, ByVal _
    lc_type As Long) As String
Dim length As Long
Dim buf As String * 1024

    length = GetLocaleInfo(locale, lc_type, buf, Len(buf))
    LocaleInfo = Left$(buf, length - 1)
End Function

Private Sub Form_Load()
Dim locale_id As Long

    '...
    locale_id = GetUserDefaultLCID()

    ' Load the values.
    ' Country.
    AddRow "Country"
    AddRow "Abbreviated Country Name", _
        LocaleInfo(locale_id, LOCALE_SABBREVCTRYNAME)
    AddRow "Native Name of Country", LocaleInfo(locale_id, _
        LOCALE_SNATIVECTRYNAME)
    '...
End Sub

' Add a row to the FlexGrid. If the second parameter
' is missing, color the row as a header.
Private Sub AddRow(ByVal item_name As String, Optional _
    ByVal item_value As Variant)
    MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1
    MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 0) = _
        item_name
    If IsMissing(item_value) Then
        MSFlexGrid1.Row = MSFlexGrid1.Rows - 1
        MSFlexGrid1.Col = 0
        MSFlexGrid1.CellBackColor = _
            MSFlexGrid1.BackColorFixed
        MSFlexGrid1.Col = 1
        MSFlexGrid1.CellBackColor = _
            MSFlexGrid1.BackColorFixed
    Else
        MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 1) = _
            item_value
    End If
End Sub

找到here

更一般地说,我对VBS国际化没有太多经验,但你可以找到一些灵感here