Xliff export and \n

I have the following in my English strings file:

"BackupFailReason"="A database integrity failure occurred.\n\nThe backup cannot be performed.";


When I export it with xcodeBuild I get:

      <trans-unit id="BackupFailReason">
        <source>A database integrity failure occurred.

The backup cannot be performed.</source>
      </trans-unit>


When this gets localized, and then given back to me, and then reimported in xcode I get:

/ (No Commment) */
"BackupFailReason" = "En database integrasjonsfeil oppsto.

Sikkerhetskopieringen kan ikke gjennomføres.";


This obviously breaks localization. What is the best way to handle this? I don't mind going through my English strings and changing them - but I don't want to lose my multi-line strings.

Replies

I hasn't been fixed for more than a year. I'm on Xcode 8.1 and I have the very same issue! I guess submitting bug reports does not make any difference

Finally I figured out. It was not \n but file location confusion.

When I exported the en.xliff file for tranlation only Main.Storyboard was localised to Base (under Base.lproj), Localized.strings were in the project's root folder. So the translated xliff files expected a source at the project root. It was fine for the first import (german) but at the same time it "localized" the file and moved it to the Base.lproj folder so the subsequent imports could not find the source file there anymore.

My workaround was to add a copy of the Localized.string file to the root again and remove it in Finder. The file will turn to red (missing) but the import proccess works fine at the end.

If anyone is still running into this issue I modified the regex to make it a bit easier. You can just find and replace in the file using (?<![;/])\n(?=[^$“/]) and \\n respectively and this should allow you to just replace all in a single click.

This is still an issue in Xcode 10.1.


Importing xliff with new line (\n) doesn't perform properly.

This is still an issue on Xcode 11.3. Importing xliff with new line (\n) doesn't perform properly.

It is unbelievable that this has not been fixed for almost 5 years...


Localizing apps in Xcode is a disaster. This should be written from the scratch

Still exists in Xcode 15.0.1 🙁