vbLocalization Manager - cLocalization

Zurück Home
 
 

The cLocalization class is the interface between your application and language files. It provides the complete functionality for language file handling.

See also: cLocalization reference

Many multilanguage solutions use resource IDs for keeping track of strings resources, that are generally stored in resource tables. Although the solution presented with vbLM is more resource wasting, it's very easy to use, implement, manage and offers runtime language switching.

ID:       If MsgBox(lc(142), vbYesNo) = vbYes Then ...
vs.
vbLM:   If MsgBox(lc("Do you want to save the file?"), vbYesNo) = vbYes Then ...

Conventions

There are coming some coding conventions with the cLocalization, which you should respect in order to prevent errors.

Use a short cLocalization object name, like 'loc' or 'lc', because you will have to use it for every string that needs to be translated.

The cLocalization class instance should be declared on global level.

As strings are combined from arguments (%N), %b is replaced with vbCRLF and %t is replaced with vbTab use this format:

MsgBox lc("The file %1 could not be found. %bDo you want to use %2 instead?", strPath, strNewPath) ...

%N is the number of the passed argument that will be inserted into the text, so it is no problem if the translator has to put %2 before %1 to make the translation sound grammatically correct.

Normally the line had looked like that:

MsgBox "The file " & strPath & " could not be found. " & vbCRLF & "Do you want to use " & strNewPath & " instead?" ...

Try not to build grammatically connected messages in runtime like the following example, because these split strings can't be translated without producing garbage.

strMsg = lngCount & IIf(lngCount = 1, " folder", " folders") & " found on " & IIf(colDrives.Count = 1, "drive " & _
              colDrives(1).Name, colDrives.Count & " drives")

Although it's not precise as in the above example, you should use:

strMsg = lc("%1 folder(s) found on %2 drive(s)", lngCount, colDrives.Count)

It's also easier to translate!

Don't use chr(255) & "=" in your source strings as this is the delimiter for OriginalText vs. Translation in the language file.

Enable runtime language change (menu or whatever) only if you have full control on all opened forms, as you need to run a specific procedure from the generated localization module to translate the control properties for each opened form.

 

 

 



© 2002-2007 VBX System