How to localize my app with Xcode 4?

2019-01-03 21:23发布

I just updated to Xcode 4.

Normally when localizing apps we add "Localizable.String" file to the project, and then navigate to "Get Info" menu and click the "Make It Localized" button.

However, in Xcode 4, there is no "Get Info" menu.

When I try to add a language it only effects the "InfoPlist.String" file (wich can only localize the app's name).

How may I add localization to my app in Xcode 4?

8条回答
时光不老,我们不散
2楼-- · 2019-01-03 21:30

You can view the file info (and add localizations) when you select the file and open the "File Inspector" via the main menu's "View" -> "Utilities" -> "File Inspector".

查看更多
Anthone
3楼-- · 2019-01-03 21:31

You can take advanced of the User Defined Runtime Attributes:

http://cupobjc.blogspot.com.es/2014/04/interfaz-builder-localization.html

First define a new category for UILabel:

#import "UILabel+Localized.h"

@implementation UILabel (Localized)
-(void) setTextLocalized:(NSString *)aText{
     [self setText:NSLocalizedString(aText, nil)];
}
@end

Then in the interface builder, User Defined Runtime Attributes :

textLocalized String your string to localized

enter image description here

And you don't need to declare the IBOutlet, and don't need code this in the ViewDidLoad [testLabel setText:NSLocalizedString(@"TEST", nil)];

查看更多
放荡不羁爱自由
4楼-- · 2019-01-03 21:33

first you need to add new Localizable.string file and select it and go to View" -> "Utilities" -> "File Inspector click on + button to add language in localization section. also check it XCode 4, Adding localization

查看更多
对你真心纯属浪费
5楼-- · 2019-01-03 21:33

Or you could use TraductoPro to automate this process for you and save a lot oftime. It is a Mac app that integrates well with Xcode.

查看更多
Rolldiameter
6楼-- · 2019-01-03 21:39

the way of Localization in xcode4 has changed! right click the localizable.strings, and to add support for another language, simply click on the ‘+’ in that ‘Localization’ pane on the right.

查看更多
我想做一个坏孩纸
7楼-- · 2019-01-03 21:42

Select the file you want to localize and klick on the file inspector in the utilities section. There is a section Localization

查看更多
登录 后发表回答