Request for additional method for the trolls

Simon Hausmann hausmann at kde.org
Fri Jan 5 15:02:39 GMT 2007


On Friday 05 January 2007 15:48, Jacob R Rideout wrote:
> > Why do you need this? Any matching being made will be most surely very
> > restricted. Why would you not have the enum in the first place?
> >
> > If you have both at some point and you need to discard one, discard the
> > string.
>
> I don't truly need the function I cited, but it would make things
> simple and Qt already has the data, it just isn't exposed. I could use
> the enum, but then I'd need to maintain some hash of my own that
> related unicode block names to the the the QLocale enum. Since Qt
> already has such a hash, it would be easier just to access it, but not
> entirely necessary.
>
> This is the highly inefficient code I am using as a quick hack. If Qt
> doesn't implement the call I suggested, I'll just use the iso code for
> the names I already know, and maintain a hash for those I don't.
> Again, before people complain, the code below won't be shipped.
>
> QString GuessLanguagePrivate::codeFromName(const QString & fullName)
> {
>     int i;
>     for (i=0;i<150;++i)
>     {
>         if ( QLocale::languageToString( (QLocale::Language)i ) == fullName)
>             return QLocale( (QLocale::Language) i ).name().left(2);
>     }

Instead of hardcoding 150 you can use QLocale::LastLanguage + 1.

Simon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070105/dc5215d8/attachment.sig>


More information about the kde-core-devel mailing list