[Kde-perl] Handling primitive type conversion in bindings (QString, QCString, QByteArray etc)

Adam Treat kde-perl@mail.kde.org
Mon, 2 Dec 2002 15:06:38 -0500


On Monday 02 December 2002 02:38 pm, Ashley Winters wrote:
> --- Adam Treat <manyoso@yahoo.com> wrote:
> > On Wednesday 27 November 2002 02:34 pm, Ashley Winters wrote:
> > > For backward compatibility, and plain old usability, all those
> >
> > classes
> >
> > > will have their "" (stringify) operator overloaded so that if you
> >
> > use
> >
> > > it like a string, it looks like a string.
> >
> > Interesting.  You plan on making QString into a bonafied PerlQt class
> > and then
> > provide a means for creation with "".
>
> That's not quite where I was going, but it's a brilliant idea
> nonetheless. I was just saying a QString, when used *as* a Perl string,
> would pretend to be a Perl string. It's also possible to overload the
> qq operator (in Perl, "foo" and qq{foo} are 100% identical, except for
> the delimiters) to create a QString. Not only that, the qq operator
> could be made to call tr() on every string in a module! This has happy
> internationalization implications.

Ahh, I've happily found out that this is also possible in C# :-)  Something 
like:

class QString
{
        public String __value__;
        public static implicit operator QString(String s)
        {
                QString retval=new QString();
                retval.__value__=s;
                return retval;
        }
}
class Foo
{
        QString x="x";
}

Now, add the translation stuff in there and we might have something that'll 
work :-)  This wasn't your original meaning, but somehow a great idea came 
out in the wash! Thanks Ashley :-)

> $label->setText("F&oo");  # identical to $label->setText(tr("F&oo"))
>
> This would be enabled pragmatically, of course. Something like:
>
> use Qt::translate;
>
> And, in order to grab all the translatable strings in a module, you
> could do:
>
> perl -MQt::translate=dump -c Module.pm
>
> It would only go through the compile stage of loading the module, and
> it would make the translate module dump out whatever format file the Qt
> translation utilities need with all the hard-coded strings in Perl.
>
> Anyone know how translation works? Should I bother the KDE i18n people?
>
> I don't wanna go away for 3 days! I need a laptop.
>
> Ashley Winters
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
> _______________________________________________
> Kde-perl mailing list
> Kde-perl@mail.kde.org
> http://mail.kde.org/mailman/listinfo/kde-perl