Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

What is the *comment parameter in:

NSString *NSLocalizedString(NSString *key, NSString *comment)

If I do this:

NSLocalizedString(@"Hello_World_Key", @"Hello World")

and have two versions of a Localizable.strings (English and Spanish), does each need the entry:

English.lproj/Localization.strings: @"Hello_World_Key" = @"Hello World";

Spanish.lproj/Localization.strings: @"Hello_World_Key" = @"Hola Mundo";

Isn't the English one redundant?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.3k views
Welcome To Ask or Share your Answers For Others

1 Answer

The second parameter is a comment that will automatically appear in the strings file if you use the genstrings command-line utility, which can create the strings file for you by scanning your source code.

The comment is useful for your localizers. For example:

NSLocalizedString(@"Save",@"Title of the Save button in the theme saving dialog");

When you run genstrings, this will produce an entry in the Localizable.strings file like this:

/* Title of the Save button in the theme saving dialog */
"Save" = "Save";

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...