Xcode 9.2 crashes exporting or importing xliff - ios

I can see that this is a recurring problem with all sorts of Xcode versions. I'm using the latest non-beta build (9.2 9C40b).
I have already localized in Spanish. Doing that involved successful exports and imports of xliff files, with same Xcode. So what changed?
I am now trying to localize to another language. This is a showstopper. Any hints? I have looked through all the posts about previous versions crashing, and have not found anything that works.
(And before you mention it, I am done and over with genstrings. If it exists anymore.)

I've discovered that large .xliff files (more than about 6,500 lines or 1,200 <trans-unit> elements) cause Xcode 10.1 to crash consistently near the end of an import operation.
The work-around is to manually split the .xliff file into two distinct .xliff files, each containing a subset of the <file> elements in the original file. You can then import the two resulting .xliff files into Xcode separately without crashing.

Do not translate "bundle name"
I wanted to translate to Greek Language and every time I was importing xliff files, Xcode was crashing.
I realized that the problem was, that I was also translating "bundle name".
If you did the same mistake, open xliff file, find:
<trans-unit id="CFBundleName">
<source>NameOfYourApp</source>
and delete the line
<target>...</target>
After that everything worked perfect for me!

Here's a workaround. Select your project icon in the Project Navigator. Select Info at top (as opposed to Build Settings). Under Localizations, click the + button and add your new language.
Xcode will create the new .strings files and fill them up with pre-existing translations. (If there are any.) Strangely, for me, some of the new .strings files were filled in with English, some with Spanish.
In any case, you have the new .strings files and can manually paste in the translations for the new language. If your app doesn't have too much user-facing text, this isn't onerous.
But really, with this problem going back to Xcode 4 (!) one would think it would be fixed by now.

it's a late answer I know, and I'm using Xcode Version 10.1 (10B61) already.
In my scenario, I added Chinese Hong Kong (zh-HK) language under Project > Info > Localization and exported successfully then sent to the agency for translations. After few days they sent to me Chinese translated text within. At that point, everything seems correct for me by eye. But I've tried 10 times to import file and it crashes 10 times without exception! Which makes me sick. I use to checked to see the difference between 2 document via Apple's File Merge App. I understand that agency geniuses added few missing <\target> tags. Hmmm, that means while exporting Xcode didn't add for some translations <\target> tag. Interesting...
I removed those unnecessarily translated tags and checked everything was equal in 2 documents except translations of the words to the Chinese language.
Tried to import again. Then BOOM! It works like a charm! I was surprised by this. It's so weird that Xcode never shows me a descriptive message about my mistake. Probably, It's just a parse error for Xcode.
Whatever, I hope this will work for someone else.
Best.

Related

How to change localisation from storyboard to strings file

TLDR: Xcode generated storyboards for each language, however I want the "old"(?) *.strings files. How?
I am currently in the process of localising my storyboards. After I enabled everything, Xcode generated another storyboard alongside the original (english) one for me to localise. I was surprised, I expected a Localizable.strings file, like the apple documentation still states as of April 3, 2021:
For storyboard and XIB interfaces, select the user interface files (files with a .storyboard or .xib filename extension). Xcode adds a strings file to the localization folder that contains the text to translate, as well as comments that describe the user interface components. For example, if you add German to an iOS app that uses storyboards, LaunchScreen.storyboard becomes a group containing a LaunchScreen.storyboard (Base) and LaunchScreen.strings (German) file.
I searched around the internet, in apple developer forums, watched both WWDC18 and 19 talks about localisation in Xcode, but did not find a single mention of translated storyboards.
After the initial translation, which works great due to the simplicity of just filling everything in, it gets frustrating however, since every layout change needs to be repeated for every language. This can't be intended, there must be a better way, right? Sadly, I didn't find anything. Even a hint to a piece of documentation regarding these storyboard copies would be greatly appreciated. Thanks!
There are some screenshots of the possibility to convert these two formats via a dropdown, like the third picture in this post. However for me, there is no dropdown next to the language item when I click the storyboard, neither on the group, nor individual base or localised ones:
Is this a bug or am I missing something here? I am using macOS Big Sur 11.2.3 with Xcode 12.4 (12D4e).
Turns out, you need to use the Base Localization feature, the dropdown then appears and you can convert existing storyboards to *.strings files.

Storyboard localization excludes a single file in iOS

I am facing a very obscure issue.
I've got an app that needs to be localized in three Languages, English, French, German. There's multiple localization files as I've got multiple storyboards ( each storyboard has one for each language).
Everything works great and things translate properly except for ONE file in ONE storyboard in ONE language. So this specific storyboard I call "Authentication" works for all languages except for the German one.
I've checked. the file is:
included in all targets
is also found in Build Phases copy phase
has the correct name.
has the correct formatting (in fact i am not allowed to build at all if the formatting is not correct in this version of Xcode.)
I am out of ideas and resorting to asking here to see if theres anything i might be missing in my series of checks.
Thanks all
SOLVED.
The answer lies within my third point
has the correct formatting (in fact i am not allowed to build at all
if the formatting is not correct in this version of Xcode.)
Beware everyone. This might seem like it is the case but it does not apply to everything. If there's a syntactic error in the Localizable.strings file, xcode will let you know and refuse to build.
HOWEVER if there's a syntax error in the YourStoryboard.strings file, the process of building will go on UNHINDERED.
Since an issue in syntax was halting everything for Localizable.strings i was wrongfully assuming that such a check would take place for all translation files. It doesnt!
Hope this saves someone in the future

Localizable string not found in strings table in iOS 9

I work in a company that has an app in production with a localization bug in iOS 9 only. The app shows the key of the localized strings, not the values. Apparently, it can't found the corresponding string in the table. On iOS 8, the app works fine.
I don't know the source code well, but I made sure the file Localization.strings is there, in the right bundle, with the correct target. I'm pretty confident the resource is there, because of tests I made and mostly because the strings are there in iOS 8!
I looked for changes in APIs in iOS 9 but couldn't find anything related to my issue. I also ran the plutil command on all the .strings files and I got OK for all of them.
Any clue as to where to look?
It turns out the app was using multiple Localization.strings file for specific localizations (tweaking the bundle and Localization system). Deleting all those files (with duplicated names) and replacing it with another system (a plist file, mainly) made it work correctly.
It seems obvious there was a conflicting name issue here, but I'm still puzzled by the fact that it worked with older iOS (8 and under).

Error while "Export For Localization.." Xcode 6.3

I want to add some new languages to my projects but after clicking Editor -> Export For Localization -> Save, I get the following error:
Localization failed reading "/var/folders/rs/_qctp1n15gl81l8s0rm7njnh0000gn/T/Xcode3SourceStringsAdaptor-2E68CCA9-A2EA-4EE4-8ED1-A9250721AFC1/Localizable.strings"
Please address the issue at file location 990
I have tried it in different projects, some working well some have this error. All projects have the same languages and are already localized I just have to add some other languages.
I have no idea what's the reason or how I can solve this problem.
I am grateful for any response!
The issue seems to be in Xcode 6.3, that the XLIFF parser suddenly chokes on unescaped quotes ('). A solution seems to be to escape (with a backslash) all instances of quotes in your source code, e.g replace #"Foobar's" with #"Foobar\'s".
Accepted answer has an issue: after exporting and import back localisations - escape sign is gone!
As #progrmr mention in comments - there is better workaround to replace ' with left single quote ’ sign! (option - shift - ] on OS X)
There's an Xcode 6.3.2 GM seed available in the developer portal downloads section. It fixed the problem for our project.
Is fixed in today release of Xcode Version 6.3.2
Be careful with XIB/Storyboard files that are localized but don't have any UI element to localize.
Those files happen to generate empty .strings files. Those empty .strings files cause the parser to throw an error, like the following: Failed to read strings file, underlying error: The data couldn't be read because it isn't in the correct format.
Removing the localization for those files worked for me.
In my case, I play the problem with these steps:
In xcode 6.3:
1. Do a regex search for \#\".\'.\" in the whole project.
2. I found no localized string have ', but quite a lot of sting in FMDB source code has SQL comment with '...
So, I Download the xcode 6.2 again, install it and "Export for Localization..." comes back!(spent me half and hour)

Xcode 6.1 - XLIFF file contains duplicated keys

I exported the localization xliff file with no errors. I localized the file, imported back to Xcode and ran the app. Everything was good.
I exported the localization xliff file again for a second-round localization. I found many keys duplicated and they are not translated, of course. Why did this happen? Is it a bug in Xcode? How to work around it?
Side Note that might be helpful: I have test targets.
I noticed this issue the other day, I think it's due to translation not being able to differentiate between the localisations, often using localisation you can be lazy by typing something like:
NSLocalizedString(#"Blue", nil);
Using nil is valid but provides no information as to the context of the translation, if the string is more verbose and that string will only be used once then nil should be fine. In the above example though the context could have multiple meanings (colour, feelings, etc) so when writing localised code ensure that if it is used multiple times add a comment for the code and as long as its the same as another localised bit of text the translated strings should merge
Example
Creates 2 localised items
NSLocalizedString(#"Blue", #"Colour");
NSLocalizedString(#"Blue", #"Feeling");
Creates 2 localised items
NSLocalizedString(#"Blue", nil);
NSLocalizedString(#"Blue", nil);
Creates 1 localised item
NSLocalizedString(#"Blue", #"Colour");
NSLocalizedString(#"Blue", #"Colour");
As I expected, the Export XLIFF file includes localisation strings in test targets too. I am using Xcode 6.2 now and still there is no way to exclude test targets from this process.
I had to open the file using a text editor (for example, TextEdit) and remove all the localisation nodes for test targets.

Resources