开发者

VBScript internationalization guidelines/best practices

Peace be upon you all!

I have been working on Internationalization and I want guidelines for VBScript. There is a lot of material for Java and JavaScript, but after extensive research on VBS, I couldnt find anything except bit and pieces of some functions like format, formatDate etcetera and no best practices/guidelines. 开发者_StackOverflow社区

What should I do?


One of the important things is to use what already exists, for instance, you can use the GetLocaleInfo API.

Something like this code:

' 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

As found here

To be more general, I don't have much experience on VBS Internationalization but you can find some inspiration here

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜