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
* C and Objective-C:
Source lines containing text of the form NSLocalizedString("key", comment) or CFCopyLocalizedString("key", comment) will generate an appro-
priate string table entry to a file named Localizable.strings.
Source lines containing NSLocalizedStringFromTable("key", Table, comment) or CFCopyLocalizedStringFromTable("key", Table, comment) will gen-
erate an appropriate string table entry in a file named Table.strings.
Source lines with NSLocalizedStringFromTableInBundle("key", Table, bundle, comment) or CFCopyLocalizedStringFromTableInBundle("key", Table,
bundle, comment) will generate an appropriate string table entry in Table.strings.
Source lines with NSLocalizedStringWithDefaultValue("key", Table, bundle, "value", comment) or CFCopyLocalizedStringWithDefaultValue("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 multiple 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).
By default, genstrings will read UTF-8 encoded source files and source files with no non-ASCII characters. Mac Roman encoded files that con-
tain 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 escape sequence are also supported.
Generated .strings files are UTF-16 encoded. Host endianness is used unless the -bigEndian or -littleEndian 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
Substitutes routine for NSLocalizedString. For example, -s MyLocalString will catch calls to MyLocalString and MyLocalStringFromTable.
Causes genstrings to skip over the file for Table. Note that any entries in this table will not be generated.
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, CFCopyLocalizedString(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 'Encoding' section above for details.
For compatibility, read source files using Mac Roman encoding. See 'Encoding' section above for details.
-q Turns off multiple key/value pairs warning
Specifies what directory the tables should be created in.
Mac OS X May 7, 2007 Mac OS X