Skip to content

Create a header file containing symbols for the given strings file keys.

License

Notifications You must be signed in to change notification settings

iKenndac/generate-string-symbols

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

What is it?

generate-string-symbols is a tiny little Mac command-line tool that creates a header file containing NSString constants for the keys in the given .strings files. Combined with a custom build step in your Xcode project and a bit of macro magic, it can be used to automatically give compile-time checked keys for your localised strings.

You can find a discussion on this over on my blog.

License

generate-string-symbols is licensed under three-clause BSD. The license document can be found here.

Building

  1. Clone create-ram-disk using $ git clone git://github.com/iKenndac/generate-string-symbols.git.
  2. Open the project and build away!

Usage

$ generate-string-symbols -strings <path to .strings file> -out <output path>

  • -strings The path to a valid .strings file.

  • -out The path to write the output header file to. Missing directories will be created along the way. If a file already exists at the given path, it will be overwritten.

Example

Given a strings file like this:

"OKTitle" = "OK";
"CancelTitle" = "Cancel";
"DownloadingTitle" = "Downloading…";

This tool will output a header file like this:

// Generated by generate-string-symbols on 2014-08-10 13:08:47 +02:00
// Source file: /Users/dkennett/Projects/Cascable/Cascable/Base.lproj/GeneralUI.strings
// WARNING: This file was auto-generated. Do not modify by hand.

#import <Foundation/Foundation.h>

static NSString * const OKTitle = @"OKTitle";
static NSString * const CancelTitle = @"CancelTitle";
static NSString * const DownloadingTitle = @"DownloadingTitle";

Note that key order isn't guaranteed.

About

Create a header file containing symbols for the given strings file keys.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published