|
|
VB Code | VB.NET Code | Java Code | ASM Code | the emulator
Internationalization / Globalization System for Visual Basic
Internationalization / Globalization System for Visual Basic.
(freeware open-source library) (outdated!)
MagicGlob is a freeware open-source library.
It allows programmer
to translate interface of any application written
in Visual Basic to any other language (French,
German, Spanish, etc...).
MagicGlob searches for all controls on a given form,
and adds information such as Menus, Captions, Texts
and Tooltips to a default language file. Later
this file can be modified by a professional
translator (or just someone who speaks a few
languages...) and loaded in application replacing
the default interface.
Click here to download MagicGlob
Steps to attach MagicGlob system to your Visual Basic project
Though it looks hard and frustrating, it's really not.
Install process is manual and may take some time,
but this makes MagicGlob very flexible.
-
Set "Startup Object" to "Sub Main" in your Project Properties
(accessible from [Project] menu).
-
Click [Add Module] from [Project] menu, and add a new module
to your project. Paste the following code inside that module:
Sub Main()
' Set to:
' 1 - to create new default language file.
' 0 - to allow forms load data from language file.
#If 1 Then
MAKE_DEFAULT_LANGUAGE_FILE
Add_To_Lang_File Form1
Add_To_Lang_File Form2
' Add more forms here or
' remove the previous line if you have only
' one form in your project!
MsgBox "Language file created!"
End ' to avoid conflicts, just exit.
#Else
LOAD_LANGUAGE_FILE
#End If
' Since we start from Sub Main,
' we should manually show the startup form:
Form1.Show
End Sub
-
Insert the following code in Form_Load() event of all
forms that you'd like to translate:
If Load_from_Lang_File(Me) Then Exit Sub
-
If there are components that you do not wish to be added
to the language file, create _ignored.dat file and use
the following format:
Form1.Text1
Form1.lbl*
(you can use built-in pattern matching)
-
You can create "_msg.dat" file with all strings that are used inside
your application (message boxes, error messages, etc...).
When you add a string to "_msg.dat" file, you should use cMT()
function to make a translation (when translation isn't done this function
just returns the same string that was passed as a parameter).
For example:
MsgBox cMT("This is a test message!")
Notes:
- Double quotes inside the string such as "" should be replaced with
a single double quote: ". For example if the source string is:
"Hello ""World!"""
it should be added to file as:
Hello "World!"
- "_msg.dat" file is used later to find a matching string
inside "_lang.dat" file. Only "_lang.dat" should be
translated and "_msg.dat" should always contain the same
strings that are used when calling to cMT() function.
-
Using [Add Module] from [Project] menu, add these existing
modules to your project: CLang.bas and modGeneral.bas
(these files are included in Sources.zip of MagicGlob pack).
-
Run your project (press F5 key), this will create "_default.dat"
file.
-
Replace this line:
#If 1 Then
with:
#If 0 Then
in Sub Main().
-
Rename "_default.dat" file to "_lang.dat".
-
"_lang.dat" is ready to be translated!
Only strings that start from the left edge of the screen should
be translated, all other data is used by MagicGlob internally.
-
These files should be distributed in a root folder of translated version of your
application:
"_lang.dat"
"_msg.dat"
In case "_lang.dat" cannot be found, the translation will not
be done, and your application will use its original interface.
This allows you to use the same executable file both for original
and translated versions of your software.
File list of Sources.zip:
- CLang.bas and modGeneral.bas - MagicGlob modules.
- Project1.vbp - sample project.
- _ignored.dat, _lang.dat, _msg.dat, Form1.*, Form2.*, Module1.bas , mssccprj.scc
- used by the sample project.
Happy coding!
|