How to localize my application with Xcode 4?

I just upgraded to Xcode 4.

Usually, when localizing applications, we add the file "Localizable.String" to the project, and then go to the "Get Information" menu and click on the "Make it Localized" button.

However, Xcode 4 does not have a Get Info menu.

When I try to add a language, it only affects the file "InfoPlist.String" (which can localize the name of the application).

How to add localization to my application in Xcode 4?

+66
xcode xcode4 internationalization localization
Mar 18 2018-11-11T00:
source share
8 answers

It is simple as soon as you understand it.

If you want to accomplish this with Xcode 5 .x and iOS 7 or Xcode 6 .x and iOS 8 , check How do I localize my application with Xcode 5? instead of this.

I liked the SNR , but his answer was a bit short.

In addition, I see that this question is a bit outdated, and my answer may be different from older versions of Xcode. (I used Xcode v. 4.3.3)

However , I updated my answer to work with both Xcode 4.3.5 and lower + 4.4 and higher (and Xcode 5.x and 6.x here: How to localize my application using Xcode 5? ).

To get started, you must add a new "line file" in the iOS resource category.

Strings file

Then create the file as "Localizable.strings". Create as

When the file is created, select it and open the “File inspector”.

The localizable fileFile inspector

EDIT : everything has changed (a bit) with the new Xcode 4.4, 4.5 (and higher) (to support iOS 6). If you are not using Xcode 4.4 or higher , skip this step.

{ Xcode 4.4, 4.5 (and later) method:

Click the Make Localized button. Make localized button

Now go to the main page of the project. Main project page

And click the "+" button in the "Localization" section and select the languages ​​you want to support.

(I will choose German / German)

List of languages

Now a window will appear asking what files you want to localize, make sure that the file "Localizable.strings" is only selected and click "Finish".

Only the "Localizable.strings" file is selected

}

{ Xcode 4.3.5 and below:

Click the "+" button in the "Localization" section and select the languages ​​that you want to support.

(I will choose German / German)

List of languages

}

.

.

.

.

You should now see that you have two files in the "Localizable.strings" file.

Localizable files

Then add localization lines to both localization files.

English

<T411>

Now here comes the coding part.

Here I simply UILabel and put it in the Localizable line.

Declare:

 IBOutlet UILabel *testLabel; 

And Inside ViewDidLoad I will set the text using NSLocalizedString :

 [testLabel setText:NSLocalizedString(@"TEST", nil)]; 

To finish, just plug our testLabel into the "Interface Builder".

Connect IBOutlet

You should now be able to run the project and see a localized string. And if you change the language, you will also see a localized string change.

English ResultChange the languageGerman result

+209
Jul 01 2018-12-12T00:
source share

Select the file you want to localize and click in the "File Utilities" section in the file inspector. There is a Localization section.

+13
Mar 18 '11 at 11:25
source share

You can view information about a file (and add localization) when you select a file and open "File Inspector" in the main menu "View" → "Utilities" → "File Inspector".

+8
Mar 30 2018-11-11T00:
source share

first you need to add a new Localizable.string file and select it and go to "View" → "Utilities" → "File Inspector" click the "+" button to add the language to the localization section. also check it out Xcode 4 by adding localization

+4
Sep 13 2018-11-11T00:
source share

localization method in xcode4 has changed! right-click locizable.strings and add support for another language, just click on the "Localization" + panel in this area on the right.

+1
Apr 14 '12 at 2:50
source share

You can use the advanced attributes of the Runtime User Defined Runtime:

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, custom runtime attributes:

textLocalized String of your string in localized

enter image description here

And you do not need to declare an IBOutlet, and you do not need this code in ViewDidLoad [testLabel setText: NSLocalizedString (@ "TEST", nil)];

+1
Apr 29 '14 at 15:48
source share

Or you can use TraductoPro to automate this process for you and save a lot of time. This is a Mac app that integrates well with Xcode.

0
Sep 19 '13 at 23:58
source share

If you need a dynamic way of switching languages ​​inside your application and using a Pods-based solution, follow these steps:

https://github.com/nullic/DPLocalizationManager

Install with: pod 'DPLocalization', '~> 1.2'

It supports the same standard localization files, but also uses dynamic linking using User Defined runtime attributes , as well as inside code like viewDidLoad .

Some examples in the project example:

  self.startup.text = DPLocalizedString(@"TITLE", nil); self.label.autolocalizationKey = @"LABEL_TEXT"; [self.label updateAutolocalizationArguments:@[@"Hello", @1234567890, [NSDate date]]]; self.autolocalizationKey = @"TITLE"; 

Download the git project, which includes a sample project showing some examples.

0
Sep 19 '14 at 3:23
source share



All Articles