VBScript 国际化指南/最佳实践

发布于 2024-12-03 05:16:01 字数 168 浏览 0 评论 0原文

愿大家平安!

我一直致力于国际化,我想要 VBScript 的指南。有很多关于 Java 和 JavaScript 的材料,但在对 VBS 进行广泛研究之后,除了一些函数(如 format、formatDate 等)的零碎内容之外,我找不到任何东西,而且没有最佳实践/指南。

我应该怎么办?

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.

What should I do?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

墨落成白 2024-12-10 05:16:01

重要的事情之一是使用已经存在的内容,例如,您可以使用 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

正如这里找到的

那样更一般,我没有太多有 VBS 国际化经验,但您可以在此处找到一些灵感

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文