Example Problem That Can Occur It is commonplace to have some user
interface strings also control program flow. This isn't a problem if the program will be
used only in one language, but it is unworkable if the program is to be localized to other
languages. These types of problems are often readily apparent because the program will
crash or there will be an obvious loss in functionality. But this isn't the case in this
example of Visdata.vbp being localized to the "$$$$" foreign language.
In this case the Visdata.vbp project
appears to be fully functional in the "$$$$" foreign language except that the
application is smaller at start-up than it normally is. A good guess is that the Height
and Width settings are not being properly read out of the Registry. The common problem for
Registry keys not being read is that one of the key strings was accidentally localized to
a foreign language and it can't be looked up.
Great care has been taken in ResMe to
avoid moving Registry related strings into the Resource file. However, due to varying
coding styles, it is impossible to arrest all inappropriate strings. It turns out
that one of the Registry key strings was accidentally placed in the Resource file and it
ended up being translated. This type of problem can be prevented by taking care to spend
more time inspecting the strings being moved to the Resource
file. Even if care is spent doing this, some mistakes will be made. This is why it is
necessary to re-test a localized application to ensure that nothing was broken.
In this example, the function
GetRegistryString() is failing because the string constant APP_CATEGORY was inadvertently moved to the Resource file.
Original Source Code That Sets
Visdata.vbp Dimensions
frmMDI.Width
= Val(GetRegistryString("WindowWidth", "9135"))
frmMDI.Height = Val(GetRegistryString("WindowHeight", "6900"))
'------------------------------------------------------------
'this function returns the Registry setting for the
'passed in item and section
'------------------------------------------------------------
Function GetRegistryString(ByVal vsItem As String, ByVal vsDefault As String) As String
GetRegistryString = GetSetting(APP_CATEGORY, APPNAME, vsItem,
vsDefault)
End Function
Public Const APP_CATEGORY = "Microsoft Visual Basic AddIns"
'Doesn't get Localized.
Public Const APPNAME = "VisData6"
Problem Introduced By
Accidentally Localizing A Registry Related String
frmMDI.Width
= Val(GetRegistryString("WindowWidth", "9135"))
frmMDI.Height = Val(GetRegistryString("WindowHeight", "6900"))
'------------------------------------------------------------
'this function returns the Registry setting for the
'passed in item and section
'------------------------------------------------------------
Function GetRegistryString(ByVal vsItem As String, ByVal vsDefault As String) As String
GetRegistryString = GetSetting(APP_CATEGORY, APPNAME, vsItem,
vsDefault)
End Function
'This
was: Public Const APP_CATEGORY = "Microsoft Visual Basic AddIns"
Public Property Get APP_CATEGORY() As String
APP_CATEGORY =
LoadResString(S438_Microsoft_Visual_Ba) <-- Localization Problem!
End Property
'This
was: Public Const APPNAME = "VisData6"
Public Property Get APPNAME() As String
APPNAME = "VisData6"
End Property
|