January 31, 2005 at 1:34 pm
I realize this isn't the place to get vb help, but I thought I'd try anyway.
But I need to change all the labels on a form from one language to another. I can store all the label texts in a table with a column for the target language. User Interface is in VB. (actually, VBA, but I figure principles are the same)
How have others done this?
Sam
January 31, 2005 at 2:07 pm
Visual Basic allows for the use of resource files, to make localization of labels very straight-forward (and so you don't have to hard code it).
If the VB program is linked into a SQL database, though, through ADO or whatever, then you can just keep the values in a table.
For instance.
create table language
(lId int identity primary key,
lName varchar(16))
insert into language (lName) values ('English')
insert into language (lName) values ('French')
insert into language (lName) values ('German')
create table formValue
(fID int identity primary key,
fFormName varchar(16),
fFormObject varchar(16))
insert into formValue (fFormName, fFormObject) values ('Login', 'txtUserName')
insert into formValue (fFormName, fFormObject) values ('Login', 'txtDomainName')
insert into formValue (fFormName, fFormObject) values ('Login', 'txtPassword')
create table formValueLanguage
(fvID int identity primary key,
lID int,
fID int,
fvPhrase varchar(32))
insert into formValueLanguage (lID, fID) values (0, 1, 'User Name')
insert into formValueLanguage (lID, fID) values (1, 1, 'Le User Nomme')
insert into formValueLanguage (lID, fID) values (2, 1, 'Userren Nammen')
insert into formValueLanguage (lID, fID) values (0, 2, 'Domain Name')
insert into formValueLanguage (lID, fID) values (1, 2, 'Le Domain Nomme')
insert into formValueLanguage (lID, fID) values (2, 2, 'Domainnen Nammen')
insert into formValueLanguage (lID, fID) values (0, 3, 'Password')
insert into formValueLanguage (lID, fID) values (1, 3, 'Le Password')
insert into formValueLanguage (lID, fID) values (2, 3, 'Passworden')
Now, in your VB program, maybe in the form load, you include something like:
adors.open "select fformObject, fvphrase from formValue v, formValueLanguage l where v.fID = l.fID and f.FormName = 'login' and lID = " & lLanguageVar, adocon, 0, 1
do until adors.eof
if adors.fields(0) = "txtUserName" then txtUserName.label = adors.fields(1)
if adors.fields(0) = "txtDomainName" then txtDomainName.label = adors.fields(1)
if adors.fields(0) = "txtPassword" then txtPassword.label = adors.fields(1)
adors.movenext
loop
Anyway, this is a just a down and dirty sloppy way of doing things. It's not the only way, and most likely not the best. But it's enough to give you an idea of how you could get it to work. Hope this helps.
David W. Clary
MCSD
Data Miner 49er
Sr. Database Administrator, Ceiva Logic
January 31, 2005 at 3:34 pm
yes. This is what I was looking for.
Sam
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply