5

How can a Unicode escape sequence be added to a string in Localizeable.strings file if the string is casted to NSString?

Here is one (ugly) example:

// Localized string: "\u{200F}Number %@" = "\u{200E}Number %@";

let string = NSMutableAttributedString(string: NSString(format: NSLocalizedString("Number %@", comment: "") as NSString, aNumber as NSNumber)) as String

From this question I understand that the problem is the incompatible escape sequences of Localizeable.strings and NSString.

Adding the unicode characters directly is Localizeable.strings file is not an option because I need to insert bidirectional semantics markers that are not printable characters. They would also be lost in most translation programs.

How can I work around that?

Manuel
  • 14,274
  • 6
  • 57
  • 130
  • Manuel, you got the solution for this? – iAmd Mar 22 '18 at 12:10
  • @iAmd If you find the question useful, then feel free to upvote it to attract more experts and maybe we get a solution for this. A workaround for me was to use the translated strings files without any copy/paste. That preserves the translator’s bi-directional semantics markers that are inserted automatically when writing RTL. If you have to change anything then make sure you change the keyboard to an RTL language. – Manuel Mar 22 '18 at 12:12
  • Does this answer your question? [iOS Localization: Unicode character escape sequences, which have the form '\uxxxx' does not work](https://stackoverflow.com/questions/23452906/ios-localization-unicode-character-escape-sequences-which-have-the-form-uxxx) – Top-Master Jun 24 '22 at 14:27

0 Answers0