Bug 162016

Summary: Unbreakable spaces are not handled in Lokalize
Product: [Applications] lokalize Reporter: Guillaume Pujol <guillp.ml>
Component: generalAssignee: Nick Shaforostoff <shafff>
Status: RESOLVED FIXED    
Severity: normal CC: jean-jacques.finazzi, karl, nicolas.ternisien
Priority: NOR    
Version: 0.1   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:

Description Guillaume Pujol 2008-05-12 22:56:17 UTC
Version:            (using Devel)
Installed from:    Compiled sources

Hi,

In french we use unbreakable spaces a lot. Unbreakable spaces are like normal spaces characters, excepted that they can't be the last character of a line. They are used to avoid some expressions or punctuation signs to be cut on line wrap.

It looks like Lokalize doesn't handle unbreakable spaces in translated messages. When opening a .po catalog which contains one, it is automatically replaced by a normal space. Lokalize need to keep unbreakable spaces in opened files.

We also need a way to type an unbreakable space in Lokalize. In KBabel this used to be Alt+Space (if I remember correctly). The same in Lokalize would be great.

Regards,
Comment 1 Karl Ove Hufthammer 2008-05-29 15:11:06 UTC
This is also needed for Norwegian. It would also be nice if unbreakable spaces were highlighted in a different colour, so that they would be easier to see.
Comment 2 Sebastien Renard 2008-05-29 15:37:05 UTC
Yes, good idea. And it would be even better if unbreakeable space could be inserted automatically when a user hit space. Of course, rules would be language dependant. For example, in French, space should be unbreable before : ; ? ! % » / and after «
Comment 3 Nick Shaforostoff 2008-05-29 15:42:17 UTC
> unbreable before : ; ? ! % »
this is candidate for script ran on saving.
Comment 4 Nicolas Ternisien 2008-05-29 15:53:41 UTC
Yes, but translators need to see if those unbreakable spaces have been correctly setted, so it would be better if those space could be added manually first. 

More over, Pology scripts already do that job.
Comment 5 Guillaume Pujol 2008-05-29 16:06:33 UTC
> More over, Pology scripts already do that job. 

The very best would be to integrate Pology into Lokalize :)

The doc is in /trunk/l10n-kde4/scripts/pology/doc/html/
Good luck ! ;)
Comment 6 Nick Shaforostoff 2008-09-13 20:34:20 UTC
this is a bug in Qt. I already submitted request.
Comment 7 Nicolas Ternisien 2008-09-15 13:45:13 UTC
Do you have the id of this bug in the Qt Bug Tracker ?
Comment 8 Nick Shaforostoff 2008-09-16 19:25:26 UTC
"
  This sounds like a bug, and I've created task 227284 for our development
  team. You can use this ID to track the status of this task online:

  http://www.trolltech.com/developer/task-tracker
  http://www.trolltech.com/customer/task-tracker
"
Comment 9 Nick Shaforostoff 2008-09-16 19:26:43 UTC
meanwhile i made entering unbreakable spaces possible. they also preserved if you don't touch them. the only case where they're lost now is when you use clipboard
Comment 10 Guillaume Pujol 2008-09-16 23:07:50 UTC
Thanks a lot :)
Comment 11 Nicolas Ternisien 2008-12-29 11:08:22 UTC
As we could see here :

http://trolltech.com/developer/task-tracker/index_html?id=227284&method=entry

The bug report has been rejected. Do you have any idea about how to close this issue ?

Thanks.
Comment 12 Karl Ove Hufthammer 2008-12-29 13:31:53 UTC
The solution would be to remove

txt.replace(QChar::Nbsp, QLatin1Char(' '));

from the QTextDocument::toPlainText() method.

But I’m really puzzled why it’s there in the first place. If the object of this method is to ‘dumb down’ down text and remove information, it should for example convert all of U+2000 to U+200A to normal spaces, neuter the quotation marks “”„‟ to ", &c (it doesn’t). But why would anyone want to do this? And why would anyone want to replace hard spaces by normal spaces? I looks like serious misdesign of the original method.
Comment 13 Nicolas Ternisien 2008-12-29 13:38:22 UTC
Yeah, that's a nonsense in my opinion, but it's probably because Qt API uses this method internally and needs this behavior. But I agree with you, the method name does not reflect this behavior.

toPlainText() should return plain text, and toAsciiPlainText() should be the right name for the actual toPlainText().
Comment 14 Karl Ove Hufthammer 2009-01-05 23:36:05 UTC
Since it’s not possible to copy non-breaking spaces, a icon for inserting them would be nice …
Comment 15 Nicolas Ternisien 2009-01-05 23:46:29 UTC
In reply to Karl :

As Nick Shaforostoff said :
meanwhile i made entering unbreakable spaces possible. they also preserved if
you don't touch them. the only case where they're lost now is when you use
clipboard

The only problem is now that copy/paste does not keep unbreakable space, so I don't think an icon for inserting them is useful
Comment 16 Karl Ove Hufthammer 2009-01-06 00:32:04 UTC
> The only problem is now that copy/paste does not keep unbreakable
> space, so I don't think an icon for inserting them is useful 

Isn’t that exactly why an icon for them *would* be useful? Since you can’t copy them from other strings or KCharselect, the only way of inserting them would be directly in Lokalize. I don’t think my keyboard layout supports inserting them directly (or at least I don’t know how to do it, or how to check it afterwards, as they are lost on copy).
Comment 17 Nicolas Ternisien 2009-01-06 01:11:06 UTC
Try Alt+Space, it works on french keyboard
Comment 18 Nick Shaforostoff 2009-01-31 20:09:37 UTC
SVN commit 919334 by shaforo:

-move almost all functionality from KAiderView to a new XliffTextEdit.
-implement clipboard handling for text with markup
-as a bonus this made unbreakable spaces preserved in clipboard operations.
BUG:162016



 M  +1 -0      CMakeLists.txt  
 M  +13 -10    catalog/catalog.cpp  
 M  +2 -1      catalog/catalog.h  
 M  +3 -2      catalog/catalogstorage.h  
 M  +23 -1     catalog/catalogstring.cpp  
 M  +17 -6     catalog/catalogstring.h  
 M  +4 -3      catalog/cmd.cpp  
 M  +3 -2      catalog/gettext/gettextstorage.h  
 M  +8 -8      catalog/pos.cpp  
 M  +7 -6      catalog/pos.h  
 M  +29 -23    catalog/xliff/xliffstorage.cpp  
 M  +3 -2      catalog/xliff/xliffstorage.h  
 M  +108 -113  kaider.cpp  
 M  +8 -8      kaider.h  
 M  +51 -51    kaider_findreplace.cpp  
 M  +88 -920   kaiderview.cpp  
 M  +39 -67    kaiderview.h  
 M  +1 -1      lokalizemainwindow.cpp  
 M  +11 -0     main.cpp  
 M  +3 -3      mergemode/mergecatalog.cpp  
 M  +1 -1      mergemode/mergecatalog.h  
 M  +1 -1      mergemode/mergeview.cpp  
 AM            xlifftextedit.cpp   kaiderview.cpp#918911 [License: GPL (v2+) (+Qt exception)]
 AM            xlifftextedit.h   kaiderview.h#918911 [License: GPL (v2+) (+Qt exception)]


WebSVN link: http://websvn.kde.org/?view=rev&revision=919334
Comment 19 Nicolas Ternisien 2009-02-02 10:08:11 UTC
Great! Thank you so much! KBabel is now definetly dead ;-)