I have found two ways to enable localization for iOS project:

  1. Creating localized .xib files
  2. Creating localized .string files

I have read up so much about both the methodologies, even I have tried both the ways. But which one should be better to use and why? Please guide me.

有帮助吗?

解决方案

The first choice is the right way to do. The number 1 reason is, not all languages are of same length. German is usually a "wider" language than English whereas Chinese is a "narrower" language. This means, if your UIButton measures 100px x 37px in English, it needs to be 130px x 37px in German and around 70px X 37px for the Chinese version. You don't have this finer controls when creating a localized string files. The downside is, if you are editing a XIB (like adding another button) you have to add it to all the XIBs. The workaround is to design one XIB to cater to the widest language and use localized string files, but then, your UI will not look polished. So at the end it boils down to a "polished UI for the user" vs "extra development time" and you have to make that decision.

Secondly, some languages like arabic are right to left and you have to customize the layout of the XIB to reflect that. (May be if it is a form, UILabel go on right and UITextFields on left?)

其他提示

Really, it depends. I usually end up with a mix of both. When layout really matters, I'll have separate .xibs. But a single .strings file is a lot more convenient to work with.

(And no, adjust to width is not a polished solution most of the time.)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top