Solved

vb6 project to handle european languages

Posted on 2001-07-24
6
386 Views
Last Modified: 2008-02-01
How can i make my vb6 project to support different european languages. i have log all the string that the  program display, i have over 2000 different strings. i was thinking of using resource files ?? is this the only way ??? if not what is the better way ?? please help.
0
Comment
Question by:LPlate
6 Comments
 
LVL 2

Expert Comment

by:idorey
ID: 6311994
I had to do this for a project which needed to be able to change the language at runtime without a restart.

We used an Access database (3000 strings) and used the AbsolutePosition settings to get each string.

It means loading the strings on each form as the form loads, but it does not seem to take much time for us since we open the recordset at program startup to keep all the strings ready.

A simple function call like GetString(1023) will return the string in the recordset at position 1023:>

Function GetString(TheNO as Long)
    MyLangStr.MoveFirst
    MyLangStr.AbsolutePosition = TheNo
    GetString = MyLangStr.Fields("String")
End Function


Dont know if this will help you but it may be an idea to give it a try. One thing though. You CANNOT delete or move items in the database sine this will mess up the AbsolutePosition of all the others.

Good luck...

0
 
LVL 2

Expert Comment

by:idorey
ID: 6311998
Forgot to mention that of course in the example above, the recordset MyLangStr is global. It gets opened when the program starts and is ready to go while it is running.

Good Luck...
0
 
LVL 3

Expert Comment

by:cmgarnett
ID: 6312003
If you don't want to use a resource file you could put a string ID in the Tag property of each control that will use a string.

Put all of your multi language strings into a database file with a language code and the string ID as the key.

When you start the application ask the user for a language code or retrieve it from the registry.

When you load the form read through all of the controls on it and if the Tag property contains a value, go and get the appropriate record from the database and populate the control's Text or Caption property.

Here's a routine for reading through all of the controls on a form.

Public Sub ShowMandatoryControls(myForm As Form)
   
   'Set the background and foreground colours for text boxes
   'depending on whether they're mandatory and/or empty
   
   Dim myControl As Control
   
   For Each myControl In myForm.Controls
      If TypeOf myControl Is TextBox Or _
         TypeOf myControl Is DataCombo Then
         If UCase(myControl.Tag) = "M" And _
            Trim(myControl.Text) = "" Then
            myControl.BackColor = vbYellow
            myControl.ForeColor = vbBlack
         Else
            myControl.BackColor = vbWindowBackground
            myControl.ForeColor = vbWindowText
         End If
      End If
   Next

End Sub

I guess, when it comes down to it, that's what resource files are doing!
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 4

Expert Comment

by:VincentLawlor
ID: 6312736
There are two ways to go here:

1. Use a resource file with multiple string tables, one for each language you wish to use.

Resource files created with the Resource Editor can contain multiple string tables, each containing strings localized for a different language. A string table will automatically be selected at run-time based on the LCID of the system; if a match isn?t found the system will load the first string table in the resource file. This model is advantageous for creating an application which will be distributed for two or more languages with no requirement for multi-language support within a single instance.

2. If you wish to dynamically select the language i.e. at run time then you can use the following approach.

Ok there is a way of doing this without changing the default locale on the machine.

Create two new ActiveX DLL projects (number of projects depends on the number of languages required
but for this example two will suffice).

Name the projects as follows
LocaleEnglish
LocaleIrish

Rename Class1 in both cases Resource

Using the Resource Add in in Visual basic add a resource to each project name the .Res files LocaleEnglish
and LocaleIrish.

Just for example add "How Are You" to the LocaleEnglish resource and "Conas ata tu" to the LocaleIrish
resource.

Add the following code to each class module.

Public Function GetResourceString(ResourceIndex As Long) As String
        GetResourceString = LoadResData(ResourceIndex, 6)
End Function

Make both ActiveX DLLs. Save the projects and close them.

You now have a means of switching between resources in your code.

Just do the following and test it.

Dim objLocalised as Object
Dim strLanguage as String
strLanguage = "English"


objLocalised = CreateObject("Locale" + strLanguage + ".Resource")

Dim strTemp as String  
strTemp = objLocalised.GetResourceString(101)

If you change the strLanguage to "Irish" you will get the Irish version of 'How are you'.

Just repeat the process for the required languages.

That should be it.

Vin.






0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7161467
Hi LPlate,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Save as PAQ -- No Refund.
    *** 3 Good answers, too few points to split.  Accepting recommendations, though.

LPlate, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 7182599
Placed in PAQ

Computer101
E-E Moderator
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question