New i18n interface for KDE 4, second try

Thomas Zander zander at kde.org
Fri Oct 28 16:09:47 BST 2005


On Tuesday 25 October 2005 16:25, Chusslove Illich wrote:
> Basic idea was to make a new class derived from QString, which has
> overridden arg() methods. This was discussed a lot, and while it would
> make least impact on existing i18n practices, almost preserving source
> compatibility, it had a need for some hacks (because QString was not
> designed for inheritance). However, due to its non-intrusivity, I feel
> this still to be an option, so I mention it here.

In a different library I wanted to introduce this kind of translations and 
I ended up with e LocalizedString class.
After working with it I found several key advantages;
* the LocalizedString class could keep the original key (the untranslated 
version) and be used in models to still show the translated version.  
This is usefull in, for example, a combobox where you can put the 
LocalizedString in the model, showing translated strings, but still 
compare the original strings when reading the result.  Effect is that 
altering the ordering of the items in the combobox; no code has to be 
altered whereas now we tend to use indexes of the selected item.

* I extended the LocalizedString and now have a LocalizedObject. This 
object contains a normal object, like a QDate and a localized string 
representation of that object.  So; we show "Yesterday" or "Jan 1, 2000" 
or whatever, but we still have the QDate in the same object.  This is 
usefull if we add it to a ListView and the ListView is sorted; now 
Yesterday does not come after "Jan 1", but we can sort on the real 
object.

* You can start demanding (in the API) LocalizedString objects in places 
that should be translated like in the constructor of a KAction.
But this last one is probably not going to be nice without deep changes in 
Qt.

I have not spent any time on the model-view stuff in Qt4, no idea how good 
it is and how well the above can integrate.  So here is just a set of 
ideas.
Oh; I had to do a toString() on my localizedString object since extending 
the string class was a no-no there as well :)

-- 
Thomas Zander
-------------- 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/20051028/92f71813/attachment.sig>


More information about the kde-core-devel mailing list