Solved

vb6 project to handle european languages

Posted on 2001-07-24
6
383 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now