Re: Getting localized NSPredicateEditor
Re: Getting localized NSPredicateEditor
- Subject: Re: Getting localized NSPredicateEditor
- From: Markus Spoettl <email@hidden>
- Date: Tue, 28 Oct 2008 15:33:45 -0700
Hi Peter,
On Oct 28, 2008, at 2:10 PM, Peter Ammon wrote:
Apple does not provide any translations of the operator names or
criteria. This is because NSPredicateEditor is designed to be
localized with sentence granularity, not word by word. Translating
each word independently and piecing them together doesn't produce as
good a localization.
For example, in Finder, you can search for "[Last modified date] is
[within last] [5] [weeks]". That whole sentence is what gets
localized - it appears in a strings file in Finder's bundle - and
there can be a separate localization for each possible sentence.
There's an example of a NSRuleEditor localized into Spanish at http://homepage.mac.com/gershwin/NibBasedSpotlightSearcher.zip
(NSPredicateEditor's localization is identical). Also see
NSNavRuleEditor.strings inside AppKit.framework/*.lproj for how the
search in the Open panel gets localized.
OK, thanks very much! That's very interesting, I would have never
figured that out from the documentation, and it appears my googling
skills are very bad.
Of course, you can localize each word independently if you prefer,
with the usual mechanism - set the title of each menu item in each
popup to the translation you want.
In my case it might even work but I'd love to give this mechanism a
try but...
Let me know if you have any questions,
I do! I tried to localize the All/Any/None sentence for the German
localization. When I do this I get an exception and the following
console log:
10/28/08 3:20:54 PM myApp[43721] Error parsing localization!
Key: %d %@
Value: %1$d %2$@
Error is: The maximum given order was 2, but nothing has order 1.
The localization part looks like this:
"%[Any]@ of the following are true" = "%[Eine]@ der folgenden
Bedingungen treffen zu";
"%[All]@ of the following are true" = "%[Alle]@ der folgenden
Bedingungen treffen zu";
"%[None]@ of the following are true" = "%[Keine]@ der folgenden
Bedingungen treffen zu";
I've set the predicate editor's formattingStringsFilename in -
awakeFromNib and implemented
- (NSDictionary *)ruleEditor:(NSPredicateEditor *)editor
predicatePartsForCriterion:(id)criterion withDisplayValue:(id)value
inRow:(NSInteger)row
{
NSMutableDictionary *result = [NSMutableDictionary dictionary];
if ([value isKindOfClass:[NSString class]]) {
if ([value isEqual:@"Any"]) [result setObject:[NSNumber
numberWithInt:NSOrPredicateType]
forKey:NSRuleEditorPredicateCompoundType];
else if ([value isEqual:@"All"]) [result setObject:[NSNumber
numberWithInt:NSAndPredicateType]
forKey:NSRuleEditorPredicateCompoundType];
else if ([value isEqual:@"None"]) [result setObject:[NSNumber
numberWithInt:NSNotPredicateType]
forKey:NSRuleEditorPredicateCompoundType];
}
return result;
}
which never gets called (probably because it's a NSPredicateEditor and
as such does not use delegate methods?). Any idea what I'm doing wrong?
Thanks very much for your help!
Regards
Markus
--
__________________________________________
Markus Spoettl
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden