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
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tools/tool
s/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();
 
 

Reply via email to