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ĂȘtre"
2, "Soumettez"
}
STRINGTABLE
LANGUAGE LANG_SPANISH, SUBLANG_SPANISH_ES
{
1, "Mi Ventana"
2, "Someta"
}
The Perl program would be something like:
...
my $Win = new Win32::GUI::Window (
-pos => [100, 100],
-size => [330, 235],
-name => "Window",
-text => LoadString(1),
-onTerminate => sub {return -1;}
);
my $but=$Win->AddButton (
-pos => [20, 20],
-size => [100, 20],
-name => "OK",
-text => 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:)
I'll do a little more playing.
Cheers,
jez.
----- Original Message -----
From: Peter Eisengrein
To: 'Jez White' ; Win32-GUI
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'}='My Window';
$text{'Spanish'}{'Window'}='Mi Ventana';
$text{'French'}{'Window'}='Ma FenĂȘtre';
$text{'English'}{'Button'}='Submit';
$text{'Spanish'}{'Button'}='Someta';
$text{'French'}{'Button'}='Soumettez';
...
[ my thanks to the Google translate tool! ]
-----Original Message-----
From: Jez White [mailto:[EMAIL PROTECTED]
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=/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.
Thoughts? Would anyone find this kind of functionality useful?
Cheers,
jez.
=============
use Win32::GUI;
use strict;
my $Win = new Win32::GUI::Window (
-pos => [100, 100],
-size => [330, 235],
-name => "Window",
-text => ":1",
-onTerminate => sub {return -1;}
);
my $but=$Win->AddButton (
-pos => [20, 20],
-size => [100, 20],
-name => "OK",
-text => ":2",
);
$Win->Show();
Win32::GUI::Dialog();