-1

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

thierryH
  • 37
  • 1
  • 6
  • Duplicate of [NSPredicateEditor & NSExpression - Can the display be different than the value for the predicate?](https://stackoverflow.com/questions/13749717/nspredicateeditor-nsexpression-can-the-display-be-different-than-the-value-f/41529823#41529823) – Willeke Dec 10 '18 at 09:41

2 Answers2

0

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.

pfandrade
  • 2,359
  • 15
  • 25
  • thanks for the blog I have updated my prog THPredicateEditorSwift on GitHub and use formattingDictionary – thierryH Dec 06 '18 at 16:19
  • the syntax is special – thierryH Dec 06 '18 at 21:35
  • which is impressive I quote Man, that’s a lot of stuff to localize! If you look closely, you can see that every occurrence of NSLocalizedString has been expanded for all possible combinations. So if you have a row template that supports 3 different left expressions, 6 different operators, and 7 different right expressions, then you have to translate 126 different things (3 * 6 * 7 = 126)." – thierryH Dec 07 '18 at 06:26
-1

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

thierryH
  • 37
  • 1
  • 6