-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathInternationalization.bas
More file actions
152 lines (123 loc) · 4.38 KB
/
Internationalization.bas
File metadata and controls
152 lines (123 loc) · 4.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
Attribute VB_Name = "Internationalization_Module"
' #VBIDEUtils#************************************************************
' * Programmer Name : removed
' * Web Site : http://www.ppreview.net
' * E-Mail : removed
' * Date : 08/11/1999
' * Time : 12:30
' **********************************************************************
' * Comments : Translate string from resource string
' *
' *
' **********************************************************************
Option Explicit
Global gnLanguage As Long
Global Const ENGLISH_LANG = 0
Global Const FRENCH_LANG = 10000
Global Const SPANISH_LANG = 15000
Global Const GERMAN_LANG = 20000
Global Const DANISH_LANG = 25000
Public Sub InternationalizeForm(theForm As Form)
' #VBIDEUtils#************************************************************
' * Programmer Name : removed
' * Web Site : www.ppreview.net
' * E-Mail : removed
' * Date : 08/11/1999
' * Time : 12:07
' * Module Name : Internationalize
' * Module Filename : Internationalize.BAS
' * Procedure Name : InternationalizeForm
' * Parameters :
' * theForm As Form
' **********************************************************************
' * Comments : Translate all the controls on a form
' * We use the ID after the µ
' *
' **********************************************************************
' #VBIDEUtilsERROR#
On Error GoTo ERROR_InternationalizeForm
Dim nI As Long
Dim nJ As Long
' *** Translate the caption of the form
theForm.Caption = Translation(CStr(theForm.Caption))
For nI = 0 To theForm.Controls.Count - 1
' *** Translate all the captions
On Error Resume Next
If TypeOf theForm.Controls(nI) Is Toolbar Then
For nJ = 1 To theForm.Controls(nI).Buttons.Count
With theForm.Controls(nI).Buttons(nJ)
.Caption = Translation(.Caption)
.ToolTipText = Translation(.ToolTipText)
End With
Next
End If
theForm.Controls(nI).Caption = Translation(CStr(theForm.Controls(nI).Caption))
theForm.Controls(nI).ToolTipText = Translation(theForm.Controls(nI).ToolTipText)
If TypeOf theForm.Controls(nI) Is TabStrip Then
With theForm.Controls(nI)
For nJ = 1 To .Tabs.Count
.Tabs(nJ).Caption = Translation(CStr(.Tabs(nJ).Caption))
Next
End With
End If
Next
EXIT_InternationalizeForm:
Exit Sub
' #VBIDEUtilsERROR#
ERROR_InternationalizeForm:
Resume EXIT_InternationalizeForm
End Sub
Public Function Translation(sText As String) As String
' #VBIDEUtils#************************************************************
' * Programmer Name : removed
' * Web Site : www.ppreview.net
' * E-Mail : removed
' * Date : 08/11/1999
' * Time : 12:07
' * Module Name : Internationalize
' * Module Filename : Internationalize.BAS
' * Procedure Name : Translation
' * Parameters :
' * sText As String
' **********************************************************************
' * Comments :
' * Translate a text using the ID in the string after the µ
' *
' **********************************************************************
' #VBIDEUtilsERROR#
On Error GoTo ERROR_Translation
Dim sTmp As String
Dim sID As String
Dim nPos As Long
Translation = sText
sTmp = ""
' *** Search the µ
nPos = InStr(sText, "µ")
' *** No Translation found
If (nPos = 0) Then
Translation = sText
Resume EXIT_Translation
End If
sID = right$(sText, Len(sText) - nPos)
' *** No identifiant found
If (IsNumeric(sID) = False) Then
Translation = left$(sText, nPos - 1)
Resume EXIT_Translation
End If
sTmp = LoadResString(gnLanguage + CLng(sID))
' *** No Translation found
If (sTmp = "") Then
Translation = left$(sText, nPos - 1)
Resume EXIT_Translation
End If
Translation = sTmp
EXIT_Translation:
Exit Function
' #VBIDEUtilsERROR#
ERROR_Translation:
If (IsNumeric(sID) = True) Then
Translation = left$(sText, nPos - 1)
Resume EXIT_Translation
End If
Resume EXIT_Translation
End Function