Anyone know what is the format for using escape chars in right-to-left languages when using iOS's internationalization feature?
A newline in left-to-right languages is \n (slash n). Does iOS's internationalization interpreter want to see a \n (slash n) or a n\ (n slash) in the Localizable.strings file when using newline char? Am adding Hebrew, as well as a handful of other L-to-R languages to an app and haven't found the correct syntax for this case. So if any of those fine Hebrew speaking iOS programmers can help out, it'd be appreciated!
In addition, an English to Hebrew translation of some verbiage yielded some double quotes in the translated Hebrew. When the Hebrew text was dropped into a tag in the (he(ebrew) language) Localizable.strings file, xcode parsed the first double quote as an end to that tags' string data. The escaping slash had to go after the double quote char. Because it didn't escape the double quote in the Hebrew text when it came before, as it does in Left-to-Right languages.
Empirically it seems that the relationship of the slash in Xcode to the escaped char is dependant on the direction of the depicted spoken languages' text. But certainly would be nice if Apple would stand up and give a definitive response so as to not cause a bug farther down the road. Because xcode is acting as the interpreter by providing the Internationalization function. Literally and figuratively.
On Google's conversion page there is a Copy button that sticks the translated text into the sys's copy buffer.
OK, let’s start with that string. If you paste that into a standalone document (UTF-16 big endian, just to make things easier to read) you’ll see this:
$ hexdump -Cv standalone.txt
00000000 05 d0 05 d5 05 de 05 e8 00 20 05 d0 05 ea 00 20 |......... ..... |
00000010 05 db 05 ea 05 d5 05 d1 05 ea 00 20 05 d4 05 d3 |........... ....|
00000020 05 d5 05 d0 00 22 05 dc |....."..|
00000028The last three code points are the ones we care about, namely:
U+05D0 HEBREW LETTER ALEF
U+0022 QUOTATION MARK
U+05DC HEBREW LETTER LAMED
btw The real problem here seems to be with your translation. The U+0022 is a compatibility thing, and the actual character to use would be U+05F4 HEBREW PUNCTUATION GERSHAYIM. If I change the doc to use that, the escaping issue becomes irrelevant and the text looks a lot nicer. However, your overall question is still valid — you may eventually encounter some right-to-left text that actually needs escaping — so let’s continue.
I then pasted that text into the Hebrew variant of a
Localizable.strings file. Here’s a hex dump of that (again in UTF-16 big endian):
$ hexdump -Cv he.lproj/Localizable.strings
…
000000f0 … 00 22 00 53 00 70 00 65 00 61 … ".S.p.e.a|
00000100 00 6b 00 20 00 74 00 68 00 65 00 20 00 65 00 6d |.k. .t.h.e. .e.m|
00000110 00 61 00 69 00 6c 00 20 00 61 00 64 00 64 00 72 |.a.i.l. .a.d.d.r|
00000120 00 65 00 73 00 73 00 22 00 20 00 3d 00 20 00 22 |.e.s.s.". .=. ."|
00000130 05 d0 05 d5 05 de 05 e8 00 20 05 d0 05 ea 00 20 |......... ..... |
00000140 05 db 05 ea 05 d5 05 d1 05 ea 00 20 05 d4 05 d3 |........... ....|
00000150 05 d5 05 d0 00 22 05 dc 00 22 00 3b 00 0a |....."...".;..|
0000015eSo Xcode’s editor hasn’t changed things; the sequence we’re focusing on, U+05D0 U+0022 U+05DC, is intact. However, the U+0022 in the middle still needs escaping.
As I mentioned earlier, Xcode interprets escape characters in Unicode storage order, so the
'\' (U+005C REVERSE SOLIDUS) needs to go before the U+0022. I inserted this with
my favourite hex editor and that makes Xcode happy.
What’s interesting is that, when I open the file in Xcode, it renders the
'\' to the right of the quote (which is the key point of confusion on your part). This happens due to Unicode’s
BiDi algorithm. The Hebrew characters in play (U+05D0 and U+05DC) are both strongly right-to-left (BiDi class
R, per Table 4 of
UAX #9). OTOH, the punctuation (U+0022 and U+005C) are ‘neutrals’ (specifically BiDi class
ON), which mean they take on the directionality of their surroundings, which is why Xcode is showing them right-to-left in this context.
So, to reiterate:
Unicode text is stored in the order in which it is to be interpreted
Xcode’s localisation support interprets escape characters in that storage order
Hebrew characters are rendered right-to-left
Punctuation characters are neutral, so rendered right-to-left when they appear inside right-to-left text
I suspect that all of this would be eminently routine to someone who is used to working with right-to-left text, so if you gave this file to a Hebrew localiser they wouldn’t be phased at all (-:
Is there a feature in Xcode that "localizes" all the text strings requested by the iTunes Connect web interface upload session.
Not within Xcode. However, there is a way to automate the process of updating all of your app’s metadata, namely iTunes Connect Transporter. For a high-level intro, watch WWDC 2015 Session 304 iTunes Connect: Development to Distribution.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"