0

I've an app that is being localized to Simplified Chinese. I've noticed that sometimes UILabels and UITextViews wrap characters but not entire words.

It seems a bit crazy to go through the Chinese language to manually point out line breaks for every single localized string for every single device size and orientation.

Is there a way to use NSLinguisticTagger to extract the words and tell UILabel to wrap based on what was tagged?

Nirav Ranpara
  • 13,753
  • 3
  • 39
  • 54
ninjaneer
  • 6,951
  • 8
  • 60
  • 104

1 Answers1

0
TextView.lineBreakMode = NSLineBreakMode.ByWordWrapping

TextView.sizeToFit()

Same for labels. It works for me not in Chinese but you can try

Lucas Palaian
  • 374
  • 2
  • 12
  • Doesn't seem to work for Chinese. Just had someone review our app and they said it's wrapping by character. – ninjaneer Jun 24 '16 at 11:26
  • Wrapping by words really just means wrapping on space characters. There are no space characters in Chinese or Japanese. To wrap Chinese or Japanese by _words_ would require the OS to have semantic and/or syntactical knowledge of your Chinese text. It just doesn't have that, so it can't do it. Compare this to most other languages (incl. Korean, for example): words are easily recognizable because they are separated by space characters. – Erik van der Neut Oct 27 '16 at 03:23