ADC Home > Reference Library > Reference > Mac OS X > Mac OS X Man Pages

 

This document is a Mac OS X manual page. Manual pages are a command-line technology for providing documentation. You can view these manual pages locally using the man(1) command. These manual pages come from many different sources, and thus, have a variety of writing styles.

For more information about the manual page format, see the manual page for manpages(5).



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

NAME
     genstrings -- generate string table from source code

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

DESCRIPTION
     The genstrings utility generates a .strings file(s) from the C, Objective-C, or Java (.c, .m, or .java)
     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 Documenta-tion. Documentation.
     tion.

     * 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.
     able.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
     Table.strings.

     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.

     * Java:

     The -j option sets the expected input language to Java.  In this case the above keywords are changed to
     Bundle.localizedString, Bundle.localizedStringFromTable, Bundle.localizedStringFromTableInBundle, and
     Bundle.localizedStringWithDefaultValue (instead of the Objective-C defaults).

     * 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.

OPTIONS
     -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
         generated.

     -noPositionalParameters
         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" =
         "ABCD".

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

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

     -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

Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.