Greenwich Setup

Greenwich is quick to set up. You'll want to download the compiled version. Once you've downloaded Greenwich, there are three parts to the setup: scripts, framework, and code.

These instructions are slightly different for iOS and Mac. Please select which version of the instructions you wish to use before you begin.

You are currently viewing the Mac setup instructions.

You are currently viewing the iOS setup instructions.

Scripts

The Greenwich download comes with a folder called Scripts. You'll need to copy this folder to a location where your build will be able to find the scripts. It is generally advisable to copy the entire folder into your project directory, but you can also put the scripts in a shared location so multiple projects can use the same installation.

Once the scripts are copied, you need to configure your Xcode project to use the scripts. This is as simple as adding a few Run Script build phases. In your Xcode project:

  1. Click on your project in the project navigator
  2. Select your application target in the targets section
  3. Switch to the Build Phases tab
  4. Click Add Build Phase
  5. Choose Add Run Script
  6. Move this build phase below the Copy Bundle Resources build phase
  7. Update the script to ./Scripts/localization create -s. -r.
  1. Click on your project in the project navigator
  2. Select your iOS target in the targets section
  3. Switch to the Build Phases tab
  4. Click Add Build Phase
  5. Choose Add Run Script
  6. Move this build phase below the Copy Bundle Resources build phase
  7. Update the script to ./Scripts/localization create -s. -r.

Add Run Script Define Run Script

Note that the script may need to be altered slightly depending on your configuration. The path to the script should relative to your project's .xcodeproj file. If you put the scripts folder in a folder called External, you would need to change the beginning of the script to ./External/Scripts/localization. The scripts also take a couple of options to allow you to specify where different files are located. If your source files and xib files are located in the same directory as your project's .xcodeproj file, then the options provided in the example above are be correct. If they're in different locations, though, you'll have to alter the arguments that are passed to the script. For most uses, you will only need to specify -s, the path to your source files, and -r, the path to your resources. Paths relative to your project's .xcodeproj file are acceptable. For example, if your source files are in a folder called Implemenation, you would need to specify -s Implementation, and if your xib files are in a folder called Interface Files, you need to specify -r "Interface Files".

Greenwich will only extract strings from unlocalized xib files. If you leave your xib files in the lproj directories, they will not be handled by Greenwich. Simply move your master out of the lproj directory if you want Greenwich to handle it. You won't need all those extra xibs any more, phew!

For an example of setting up the scripts using the PATH environment variable, check out the example application included with the source code.

Framework (Copying & Linking)

Framework

Linking and copying the framework is similar to other Mac OS X frameworks. The distribution includes the framework which you should copy to a location where your project can access it. Again, it is generally advisable to copy the framework into your project directory. Once in place, there are just a few steps to getting it added into your project:

Linking framework is similar to other iOS frameworks. The distribution includes the framework which you should copy to a location where your project can access it. Again, it is generally advisable to copy the framework into your project directory. Once in place, there are just a few steps to getting it added into your project:

  1. Activate the project navigator in Xcode
  2. Drag Greenwhich.framework into the Frameworks group
  3. Xcode will display a dialog for adding files
  4. Make sure your application target is checked, then click Finish
  5. Click on your project in the project navigator
  6. Select on your target in the targets section
  7. Switch to the Build Settings tab
  8. Set Runpath Search Paths to @executable_path/../Frameworks
  9. Switch to the Build Phases tab
  10. Click Add Build Phase
  11. Choose Add Copy Files
  12. Change the Destination to Frameworks
  13. Drag Greenwich.framework from the project navigator into the copy files list

Drag Framework Add Framework Set Runpath Search Paths Copy Framework

  1. Activate the project navigator in Xcode
  2. Drag Greenwhich.framework into the Frameworks group
  3. Xcode will display a dialog for adding files
  4. Make sure your application target is checked, then click Finish
  5. Click on your project in the project navigator
  6. Select on your target in the targets section
  7. Switch to the Build Settings tab
  8. Set Other Linker Flags to -ObjC -all_load

Drag Framework Add Framework

Code

At this point, you still need to add a little code to your application, but this is easy:

#import <Greenwich/Greenwich.h>

@interface MyAppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)notification {
    [[FRLocalizationManager defaultLocalizationManager] installExtraHelpMenu];
}

@end
#import <Greenwich/Greenwich.h>

@interface MyAppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)notification {
    [FRLocalizationManager defaultLocalizationManager];
}

@end

When you launch the application, you can bring up the translator by holding down option while opening the Help menu... easy peasy.

Your application now includes everything necessary to use Greenwich. Simply launch the translator tool that comes with the Greenwich download, and it will connect to your device... easy peasy.

Usage

Once you've set everything up, you're good to go. Greenwich will work with your existing calls to NSLocalizedString and will translate all your xib files as they're loaded. In certain cases, however, you may find that you need to make a few changes to the positions of UI elements after localization has occurred. Don't worry, we've got you covered:

- (void)awakeFromLocalization {
    // calculate the size of ui elements & reposition things
}

If you're using your own macro based off of NSLocalizedString, simply define the GREENWICH_LOCALIZATION_SYMBOL in your Xcode configuration with that symbol, and Greenwich will handle it from there!

Setting the environment variable GREENWICH_PSEUDO_LOCALIZE will make Greenwich pseudo-localize your application. It will swap out certain characters and extend your strings slightly while keeping them identifiable. This setting is great for testing to make sure that everything is localized and that you've allowed enough space for strings in other languages.

Extras

There's also a guide that you can customize and send to your translators.

Greenwich includes a proofer tool that will allow you to validate user translations.

Greenwich is an open source project brought to you by FadingRed.