Mac Developer Library Developer


This manual page is for Mac OS X version 10.9

If you are running a different version of Mac OS X, view the documentation locally:

  • In Terminal, using the man(1) command

Reading manual pages

Manual pages are intended as a quick reference for people who already understand a technology.

  • To learn how the manual is organized or to learn about command syntax, read the manual page for manpages(5).

  • For more information about this technology, look for other documentation in the Apple Developer Library.

  • For general information about writing shell scripts, read Shell Scripting Primer.

genstrings(1)             BSD General Commands Manual            genstrings(1)

     genstrings -- generate string table from source code

     genstrings [-a] [-s <routine>] [-skipTable <Table>] [-noPositionalParameters]
                [-bigEndian | -littleEndian] [-u] [-macRoman] [-q] [-o <outputDir>] file

     The genstrings utility generates a .strings file(s) from the C or Objective-C (.c or .m) source code
     file(s) given as the argument(s).  A .strings file is used for localizing an application for different
     languages, as described under "Internationalization" in the Cocoa Developer Documentation.

     * C and Objective-C:

     Source lines containing text of the form NSLocalizedString("key", comment) or CFCopyLocalized-String("key", CFCopyLocalizedString("key",
     String("key", comment) will generate an appropriate string table entry to a file named Localiz-able.strings. Localizable.strings.

     Source lines containing NSLocalizedStringFromTable("key", Table, comment) or CFCopyLocalized-StringFromTable("key", CFCopyLocalizedStringFromTable("key",
     StringFromTable("key", Table, comment) will generate an appropriate string table entry in a file named

     Source lines with NSLocalizedStringFromTableInBundle("key", Table, bundle, comment) or CFCopyLocalized-StringFromTableInBundle("key", CFCopyLocalizedStringFromTableInBundle("key",
     StringFromTableInBundle("key", Table, bundle, comment) will generate an appropriate string table entry
     in Table.strings.

     Source lines with NSLocalizedStringWithDefaultValue("key", Table, bundle, "value", comment) or CFCopy-LocalizedStringWithDefaultValue("key", CFCopyLocalizedStringWithDefaultValue("key",
     LocalizedStringWithDefaultValue("key", Table, bundle, "value", comment) will generate an appropriate
     string table entry in Table.strings.

     * Format Strings and Positional Parameters:

     Keys and values of string file entries can include formatting characters.  For value strings with mul-tiple multiple
     tiple formatting arguments, positional parameters are generated.  These allow the order of arguments to
     be changed as needed by each localization (e.g. "File %1$@ contains %2$d bytes." could become "%2$d
     bytes are contained in file %1$@." in another localization).

     * Encoding:

     By default, genstrings will read UTF-8 encoded source files and source files with no non-ASCII charac-ters. characters.
     ters.  Mac Roman encoded files that contain non-ASCII characters will not be read successfully unless
     the -macRoman compatibility flag is used.  Developers are strongly encouraged to move to UTF-8 as the
     encoding for source files as the -macRoman option may be removed in future versions.

     Embedded non-ASCII characters in UTF-8 files, as well as non-ASCII characters specified by the escape
     sequences \uxxxx and \Uxxxxxxxx are read automatically by genstrings.  The -u option and genstrings-specific genstringsspecific
     specific escape sequence are also supported.

     Generated .strings files are UTF-16 encoded.  Host endianness is used unless the -bigEndian or -lit-tleEndian -littleEndian
     tleEndian option is specified.  The endian options do not affect .strings files being appended to with
     the -a option.  The byte order of the existing file is maintained.

     -a  Allows the output to be appended to the old output files. However, -a causes the results to be
         appended to the end of the old file and not merged.

     -s routine
         Substitutes routine for NSLocalizedString.  For example, -s MyLocalString will catch calls to MyLo-calString MyLocalString
         calString and MyLocalStringFromTable.

     -skipTable Table
         Causes genstrings to skip over the file for Table.  Note that any entries in this table will not be

         Turns off generation of positional parameters.

     -u  Allow unicode characters in the value of strings files.  Any occurrence of \\Uxxxx (where xxxx are
         four hex digits) in the source code will be written to the strings file with its Unicode value (in
         terms of \\Uxxxx) for the key, but the actual Unicode value for its value.  For Example, CFCopyLo-calizedString(CFSTR("AB\\U0043D"), CFCopyLocalizedString(CFSTR("AB\\U0043D"),
         calizedString(CFSTR("AB\\U0043D"), "Comment") will result in the key/value pair "AB\\U0043D" =

         Note that non-ASCII characters can now be handled automatically without this option.  See 'Encod-ing' 'Encoding'
         ing' section above for details.

         For compatibility, read source files using Mac Roman encoding.  See 'Encoding' section above for

     -q  Turns off multiple key/value pairs warning

     -o outputDir
         Specifies what directory the tables should be created in.

Mac OS X                          May 7, 2007                         Mac OS X

Reporting Problems

The way to report a problem with this manual page depends on the type of problem:

Content errors
Report errors in the content of this documentation with the feedback links below.
Bug reports
Report bugs in the functionality of the described tool or API through Bug Reporter.
Formatting problems
Report formatting mistakes in the online version of these pages with the feedback links below.