[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    How properly convert language codes from KGlobal::locale() into RFC 5646 (used in xml:lang attribute
From:       Nikolay Shaplov <n () shaplov ! ru>
Date:       2012-01-28 17:05:32
Message-ID: 201201282105.33165.n () shaplov ! ru
[Download RAW message or body]

Hi!

I am going to write patch for KNetworkManager's mobile connection wizard, that 
will properly choose apn's name according to system locale, and I need help.

In serviceproviders.xml along with APN's info comes APN screen name, sometimes 
international name and local name are provided:

                        <apn value="internet.sib">
                                <plan type="postpaid"/>
                                <usage type="internet"/>
                                <name>sib</name>
                                <name xml:lang="ru">Сибирь</name>
                                <dns>83.149.51.65</dns>
                                <dns>83.149.50.65</dns>
                        </apn>
                        <apn value="internet.volga">
                                <plan type="postpaid"/>
                                <usage type="internet"/>
                                <name>volga</name>
                                <name xml:lang="ru">Поволжье</name>
                                <dns>83.149.16.7</dns>
                                <dns>195.128.128.1</dns>
                        </apn>

Now when connection is created the last name entry is chosen (ignoring the 
xml:lang tag) What might be not comfortable for users that does not speak 
local language.

I'd like to write a patch that chooses proper name according to 
KGlobal::locale()->languageList() settings. But I met a problem:

In xml:lang property language is coded according to RFC 5646 (i.e. en-
us)

But KGlobal::locale()->languageList() returns language code in 'en_US' format 
(even do not know what RFC is that, google does not help ;-) )

If it was just home-made script, I would do lowercase to KGlobal::locale()'s 
language code and replace '_' with '-'.

But as far as it is not home-made script, I would like to find some wiser 
solution.

Are there some API functions or some guidelines how to convert language codes 
from KGlobal::locale() style into RFC 5646 ?  Or lowercase and replace 
will do?

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic