简体   繁体   中英

localization NSPredicateEditor / NSPredicateEditorRowTemplate

what I want to get

how make a localisation with NSPredicateEditorRowTemplate

it is not well documented it was a total pain to figure out.

all is written programmatically

I would like a French, Italian version etc.

https://github.com/thierryH91200/THPredicateEditorSwift

Localizing an NSPredicateEditor is a bit more involved than usual localisation.

First, you'll need to have NSLocalizedString() calls in your code somewhere so that genstrings is able to find them.

Secondly, the key needs to follow a special format that will instruct genstrings to produce all combinations of a given row:

NSLocalizedStringFromTable(@"%[Any, All, None]@ of the following are true", @"Predicate", @"localize the compound row template")
NSLocalizedStringFromTable(@"%[property]@ %[is, is not, contains, begins with, ends with, like, matches]@ %@", @"Predicate", @"localize the string row template")
NSLocalizedStringFromTable(@"%[birthMonth]@ %[is, is not]@ %[January, February, March, April, May, June, July, August, September, October, November, December]@", @"Predicate", @"localize the selection row template")

In the example above genstrings will look at the options between brackets and generate a localisation string for all combinations in the Predicate.strings file.

Finally, you must let your NSPredicateEditor instance know which strings file to use by setting the formattingStringsFilename property.

See this blog post for more information.

the blog is a few years old.

xcode has improved over the years.

the question is duplicate but the answers may be different a few years later.

the answer is simple. it is the localization of the xib file and it works perfectly

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM