Bug 227366 - Line breaks are not imported / exported correctly
Summary: Line breaks are not imported / exported correctly
Status: RESOLVED FIXED
Alias: None
Product: Babel
Classification: Technology
Component: Server (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P1 normal (vote)
Target Milestone: GANYMEDE   Edit
Assignee: Babel Bugzilla inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2008-04-16 11:57 EDT by Masahiro Arai CLA
Modified: 2008-06-03 15:23 EDT (History)
2 users (show)

See Also:


Attachments
Screen shot of the UI which has this issue (28.74 KB, image/pjpeg)
2008-04-16 11:57 EDT, Masahiro Arai CLA
no flags Details
patch for 227366 (527 bytes, patch)
2008-05-13 04:30 EDT, Motoki MORI CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Masahiro Arai CLA 2008-04-16 11:57:40 EDT
Created attachment 96275 [details]
Screen shot of the UI which has this issue

Build ID: N/A

Steps To Reproduce:
1. Download German language pack from babel update site
2. Start Eclipse on German locale
--> You'll see that line breack is not correctly used

More information:
This may related with bug 227363.
Also, root cause might be how those strings are imported into database

Followings are related entries from English / German property file 

English one:

ChooseWorkspaceDialog_dialogMessage= \

{0} stores your projects in a folder called a workspace.\n\

Choose a workspace folder to use for this session.

 

German one (no line break & incorrect line break \\n\\\n):

ChooseWorkspaceDialog_dialogMessage={0} speichert Ihre Projekte in einem Ordner, der als Arbeitsbereich bezeichnet wird.\\n\\\nW\u00e4hlen Sie einen Arbeitsbereichsordner aus, der f\u00fcr diese Sitzung verwendet werden soll.
Comment 1 Kit Lo CLA 2008-04-28 09:57:09 EDT
I checked the database, the translation was saved properly in German (and all other languages). This is how the German translation looks like:

{0} speichert Ihre Projekte in einem Ordner, der als Arbeitsbereich bezeichnet wird.\n\
Wählen Sie einen Arbeitsbereichsordner aus, der für diese Sitzung verwendet werden soll.

The problem happens when we generate the language packs.
json_encode($strings_row['trans']) was called.

/*
 * Iterate over every character in the string,
 * escaping with a slash or encoding to UTF-8 where necessary
 */
for ($c = 0; $c < $strlen_var; ++$c) {
  $ord_var_c = ord($var{$c});
  switch (true) {
    ...
    case $ord_var_c == 0x22:
    case $ord_var_c == 0x2F:
    case $ord_var_c == 0x5C:
      // double quote, slash, slosh
      $ascii .= '\\'.$var{$c};
      break;
    ...

json_encode() escaped the back-slashes in "\n\" and produced "\\n\\".

Not sure if we should modify the json_encode() code not to escaped the back-slashes.
Comment 2 Kit Lo CLA 2008-04-28 10:03:40 EDT
Just saw that we are stripping the quotes around strings returned by json_encode(). Maybe we shoudl strip the extra back-slashes at the same time.

# json_encode returns the string with quotes fore and aft.  Need to strip them.
$tr_string = preg_replace('/^"(.*)"$/', '${1}', json_encode($strings_row['trans']));
Comment 3 Motoki MORI CLA 2008-05-13 04:30:39 EDT
Created attachment 99900 [details]
patch for 227366

In accordance with the comment of Kit-san, we tried to make a patch for classes/export/generate1.php. However due to the complexity of making test environment, we have not enough tested it yet. Please check and test it.
Comment 4 Denis Roy CLA 2008-05-13 14:23:41 EDT
Thanks for the patch.  I have applied and committed it, and I ran a test update site.

    http://build.eclipse.org/technology/babel/test-updates/

Please confirm that the patch works as expected.
Comment 5 Motoki MORI CLA 2008-05-13 23:03:13 EDT
Thank you for your cooperation. We checked the behavior of the tool and the result of .properties file. It worked as expected.
Comment 6 Denis Roy CLA 2008-06-02 13:41:45 EDT
We think this is related to bug 222660.

Can you start launch a fresh copy of Eclipse and install the language
pack from this update site, and see if the problem is solved:

For Eclipse 3.4 :
http://build.eclipse.org/technology/babel/test-updates/ganymede/


Thanks
Comment 7 Denis Roy CLA 2008-06-03 15:23:02 EDT
Closing as fixed -- I'm pretty confident this was a dupe of 222660.