Bug 227366

Summary: Line breaks are not imported / exported correctly
Product: [Technology] Babel Reporter: Masahiro Arai <masahiro.arai>
Component: ServerAssignee: Babel Bugzilla inbox <babel.core-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P1 CC: kitlo, mori-m
Version: unspecifiedKeywords: contributed
Target Milestone: GANYMEDE   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Screen shot of the UI which has this issue
none
patch for 227366 none

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.