Hi,
I was really impressed by your use of French and Spanish - until I read =
the google statement:)
There are lots of ways to do this. In my case, I have over a thousand =
controls (sounds a lot, but when you add up all the labels, group boxes =
etc!), so maintaining a perl hash becomes problematic - ideally, the =
translations should be in a separate file or database, so they can be =
worked on separately.
I've done a little more digging on the string table functionality, and =
it seems it is more powerful and simpler than I first thought. Using =
your example as a base:
The string table would be added to the runtime exe (or the perl exe =
during development):
STRINGTABLE
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
{
1, "My Window"
2, "Submit"
}
STRINGTABLE
LANGUAGE LANG_FRENCH, SUBLANG_FRENCH_FR
{
1, "Ma Fen=EAtre"
2, "Soumettez"
}
STRINGTABLE
LANGUAGE LANG_SPANISH, SUBLANG_SPANISH_ES
{
1, "Mi Ventana"
2, "Someta"
}
The Perl program would be something like:
...
my $Win =3D new Win32::GUI::Window (
-pos =3D> [100, 100],
-size =3D> [330, 235],
-name =3D> "Window",
-text =3D> LoadString(1),
-onTerminate =3D> sub {return -1;}
);
my $but=3D$Win->AddButton (
-pos =3D> [20, 20],
-size =3D> [100, 20],
-name =3D> "OK",
-text =3D> LoadString(2),
);
...
According to the MS docs, the correct strings will be brought in at =
runtime. French on a French machine, Spanish on a Spanish =
machine...Instant internationalization:)=20
I'll do a little more playing.
Cheers,
jez.
----- Original Message -----=20
From: Peter Eisengrein=20
To: 'Jez White' ; Win32-GUI=20
Sent: Tuesday, May 11, 2004 4:50 PM
Subject: RE: [perl-win32-gui-users] Internationalization and =
Win32::GUI
If the text were to always be the same, I would say yes it would be a =
useful function. But if the text would usually be customized (which I =
would expect), then it might be easier to just use a hash of hashes:
$text{'English'}{'Window'}=3D'My Window';
$text{'Spanish'}{'Window'}=3D'Mi Ventana';
$text{'French'}{'Window'}=3D'Ma Fen=EAtre';
$text{'English'}{'Button'}=3D'Submit';
$text{'Spanish'}{'Button'}=3D'Someta';
$text{'French'}{'Button'}=3D'Soumettez';
...
[ my thanks to the Google translate tool! ]
-----Original Message-----
From: Jez White [mailto:jez@...]
Sent: Tuesday, May 11, 2004 8:16 AM
To: Win32-GUI
Subject: [perl-win32-gui-users] Internationalization and Win32::GUI
Hi,
Has anyone tried to create an application for Win32::GUI that =
supports various natural languages?
I've worked on production applications that had to provide this kind =
of support in the past, so I've got a rough idea how the whole process =
should work. Adding the various windows API internationalization =
functions to the core is quite straight forward, but I'm struggling with =
how to handle text for all the windows and controls. Clearly, having =
several sets of creation routines for each natural language is not the =
correct approach:) As a rough design concept, how about using string =
tables and dynamic text replacement in runtime?
=
http://msdn.microsoft.com/library/default.asp?url=3D/library/en-us/tools/=
tools/stringtable_resource.asp
Instead of hardcoding each -text item as the natural language, you =
use a code (in the example below, I've used ":" to signify a text look =
up should be used). On the control creation, the ID would be used (with =
a language offset) to retrieve the text for the current natural =
language, this text would then be used with the control. This would be =
handled automatically, and transparently from the Perl script.=20
Thoughts? Would anyone find this kind of functionality useful?
Cheers,
jez.
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
use Win32::GUI;
use strict;
my $Win =3D new Win32::GUI::Window (
-pos =3D> [100, 100],
-size =3D> [330, 235],
-name =3D> "Window",
-text =3D> ":1",
-onTerminate =3D> sub {return -1;}
);
my $but=3D$Win->AddButton (
-pos =3D> [20, 20],
-size =3D> [100, 20],
-name =3D> "OK",
-text =3D> ":2",
);
=20
$Win->Show();
Win32::GUI::Dialog();
|