A multilingual software development tool designed for VB makes it easy to achieve multiple languages for visual interfaces.

Source: Internet
Author: User
Tags integer pack resource

VB system for the Multilingual Software development tool, you can easily complete the visual interface of the multilingual, you only need to make a language pack motherboard after the translation copy of the motherboard can be. Click here to download the sample project.

The interface is described as follows:

Start icon:
Click here to start the program.

The program adds the following code to your code so that you can access the language pack:

Api:
Private Declare Function getprivateprofilestring Lib "kernel32" Alias "Getprivateprofilestringa" (ByVal Lpapplicationname As String, ByVal lpkeyname as any, ByVal Lpdefault as String, ByVal lpreturnedstring as String, ByVal NS Ize as Long, ByVal lpFileName as String) as Long
Because the language pack is saved in the INI format, the program adds the API function and does not add if the API already exists.

Add code that invokes the interface language loader in the form's Load event.
Private Sub Form_Load ()
Call Frmmain.coderhelper_vbmltlug_initfrmmain (App.Path + IIf (Len (App.Path) = 3, "", "\") + App.EXEName + ". Exe.lag") ' Code Rhelper dedicated code line please do not delete!
The procedure in parentheses is the file path and file name for the computed language pack file. The file name is a file with the name ". Lag" followed by the path to the executable file. To translate the file, copy it and open the translation using the Text tool. In subsequent releases, a partial translation and conversion tool will be provided.

Adds an interface initializer. The program's parameters are the full path to a valid language pack file.
Public Sub Coderhelper_vbmltlug_initfrmmain (lngfilename as String)
' Mysticboy reminds you that the following code is recommended for debugging because the properties of some controls may be read-only or unavailable at run time.
Me.CmdDown.Caption = Ch_getkeyval (Lngfilename, "Frmmain.cmddown", "Caption", "V")
{......}
End Sub
Because some of the properties of some controls are read-only or unavailable at run time, it is recommended that you debug the code before you compile the project.

This function will be used to access the language pack file, read the value of the specified key in the specified field, or use the default value if the language pack is invalid or not, that is, the Defvalue parameter specifies a value.
Public Function Ch_getkeyval (ByVal FileName As String, ByVal section as String, ByVal Key as String, Optional defvalue as String)
Dim RetVal as String, worked as Integer
If Dir (FileName) <> "" and filename <> "" Then
RetVal = string$ (255, 0)
worked = getprivateprofilestring (section, Key, defvalue, RetVal, Len (RetVal), FileName) If worked = 0 Then
Ch_getkeyval = Defvalue
Else
Ch_getkeyval = Left (RetVal, InStr (RetVal, Chr (0))-1)
End If
Else
Ch_getkeyval = Defvalue
End If
End Function

This function is used to read a string within the specified language pack. A string may include text such as hints in code or captions for forms.
Public Function Ch_getstr (Key As String, Optional Defvalue as String) '
' Use this function to read string information ' such as I = MsgBox (Prompt:=ch_getstr ("SaveFile", "File is saved?"), Title:=ch_getstr ("SaveFile1", "File Not Saved"), Buttons : =vbyesno) '
Ch_getstr = Ch_getkeyval (App.Path + IIf (Len (App.Path) = 3, "", "\") + App.EXEName + ". Exe.lag", "Strings", Key, Defvalue)
End Function
' If you have other arrangements for the language pack, rewrite the code.

Suggest adding code:
Example Project, we used this code to load the language, First, place the translated language pack file in the resource file. Then use the following diameter to read the resource to save to the file with the full path name of the Coderhelper default language pack file. The loader is then invoked to load the language.
Private Sub Meng_click ()
on Error GoTo errh
Dim lagfn As String, fn as Long
Dim ary () as Byte
fn = Freefil E
Lagfn = App.Path + IIf (Len (App.Path) = 3, "", "\") + App.EXEName + ". Exe.lag"
Open lagfn for Binary as #fn
ary = LoadResData ("lag") ' lag is the resource type, 103 is the resource code for the current language pack.
put #fn, ary
Close #fn
Call Frmmain.coderhelper_vbmltlug_initfrmmain (App.Path + IIf (App.Path) = 3, "", "\ ") + App.EXEName +". Exe.lag ") ' loads language.
Errh:
If err.number <> 0 Then
MsgBox err.description, vbinformation
End If
End Sub
' Multiple languages are placed in resources. Will facilitate your access. While loading different languages, using this suggestion code, only need to change is ary = LoadResData ("lag"), you just have to change the resource ID number, multi-language, recommend the best use of the control array.
Private Sub Munlag (Index as Integer)
[...]
Ary=loadresdata (100+index, "lag")
[...]
End Sub
This is the method suggested by Mysticboy ...

Note: Do not take "Coderhelper dedicated line of code" in the line of code you write please do not delete! Such content. otherwise. When the code is regenerated, Coderhelper is considered to be the code that was added when the Coderhelper last worked. will be deleted before inserting new code.

This tool is a formally released component for Coderhelper, so the product needs to be registered. In the case of not registering. The frequency of the use of other coderhelper advanced components will be counted together, limited to 50 times.

Finally, I wish your software development success.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.