DMLocalizedNibBundle
is Wil Shipley's localization
system
with improvements to support localization of:
- all
NSTabView
items and their labels - columns in
NSTableView
andNSOutlineView
- display patterns (
%{value1}
,%{value2}
, ...) inNSTextField
strings
I've tested the code on the Mac OS X 10.10 SDK.
It should run fine on the 10.8 SDK too, though I haven't tested this.
If you need 10.7 compatibility checkout the tag 10.7-compatibility
.
Note that the following instructions are for Xcode 4.3.
First create a target for the command-line tool that will slurp out the localizable strings from source files and XIB files:
- In Xcode choose File > New > Target
- On the left select "Application" under the Mac OS X heading
- On the right select "Command Line Tool" and click Next
- For the Target Name enter "xibLocalizationPostprocessor"
- For the type select "Foundation"
- Deselect "Use Automatic Reference Counting"
- Click Finish
- In the Project Navigator find the newly added "xibLocalizationPostProcessor" group
- Ctrl-click on the group and choose Delete
- Choose "Move to Trash"
- Drag "xibLocalizationPostprocessor.m" into your project
- Under Add To Targets list select only xibLocalizationPostprocessor and deselect all others
- In the Project Navigator select your project
- From the Targets select "xibLocalizationPostprocessor"
- Click Build Settings
- Clear the "Precompile Prefix Header" and "Prefix Header" build settings
The "xibLocalizationPostprocessor" target should now compile.
Next set the above command-line tool to be compiled with the application:
- In the Project Navigator select your project
- From the Targets select your application target
- Click Build Phases
- Under Target Dependencies click "+"
- Select xibLocalizationPostprocessor and click Add Target
Then add a build script that will call the above command-line tool:
-
In the Project Navigator select your project
-
From the Targets select your application target
-
Click Build Phases
-
Click "Add Build Phase" and choose "Add Run Script"
-
In the Script text view enter
/path/to/slurpLocalizableStrings.zsh
For example if you have the localization project as a subfolder in the Xcode project folder:
${SRCROOT}/DMLocalizedNibBundle/slurpLocalizableStrings.zsh
-
Rename the build script phase "Generate Localizable Strings" or something to your liking
And finally add the dynamic localization loader into your application target:
- Drag
DMLocalizedNibBundle.m
into your project - Under Add To Targets list select only your application target and deselect all others
Created by William Jon Shipley on 2/13/05. Copyright © 2005-2009 Golden % Braeburn, LLC. All rights reserved except as below:
This code is provided as-is, with no warranties or anything. You may use it in your projects as you wish, but you must leave this comment block (credits and copyright) intact. That's the only restriction -- Golden % Braeburn otherwise grants you a fully-paid, worldwide, transferrable license to use this code as you see fit, including but not limited to making derivative works.
Changes made by Incredible Bee Ltd. are also under the above license.