Getting localized NSPredicateEditor

2008-10-28 Thread Markus Spoettl

Hello List,

  is there a way to make NSPredicateEditor play nice with localized  
versions of an application, meaning that it's rule operators and  
criteria are translated to the language the rest of the application is  
using?


Right now it appears that NSPredicateEditor uses English operator  
names (and compound criteria descriptions), regardless of which  
language is used.


Regards
Markus
--
__
Markus Spoettl



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: Getting localized NSPredicateEditor

2008-10-28 Thread Peter Ammon


On Oct 28, 2008, at 1:12 PM, Markus Spoettl wrote:


Hello List,

 is there a way to make NSPredicateEditor play nice with localized  
versions of an application, meaning that it's rule operators and  
criteria are translated to the language the rest of the application  
is using?


Right now it appears that NSPredicateEditor uses English operator  
names (and compound criteria descriptions), regardless of which  
language is used.


Regards
Markus



Hi Markus,

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.


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.


Let me know if you have any questions,
-Peter

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Getting localized NSPredicateEditor

2008-10-28 Thread Markus Spoettl

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



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: Getting localized NSPredicateEditor

2008-10-28 Thread Markus Spoettl

Hi Peter,

On Oct 28, 2008, at 3:33 PM, Markus Spoettl wrote:

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:



Never mind the previous mail. I put the localization in its own file  
and it works. I had it in Localizable.strings with tons of other stuff  
in it and apparently the system does expect it to be on its own.


Time for some more experimenting, thanks very much for the quick help!

Regards
Markus
--
__
Markus Spoettl



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: Getting localized NSPredicateEditor

2008-10-28 Thread Peter Ammon


On Oct 28, 2008, at 3:33 PM, Markus Spoettl wrote:


Hi Peter,


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.


My guess is that you're using the same strings file for this and other  
uses. The %[...]@ syntax is unique to NSRuleEditor/NSPredicateEditor  
and so it needs its own strings file.  %d should never appear in one  
of these strings.


Here's something that may help - there's a method on NSRuleEditor: - 
(NSData *)_generateFormattingDictionaryStringsFile.  It gives you a  
strings file (as UTF16 data) appropriate for that control - write the  
data to a .strings file and then you can start translating it.


That method should never be called in production code but it can be  
useful for generating the strings file.



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?).


Right, those delegate methods are not used for NSPredicateEditor.  All  
that's necessary for localization is to set the strings file.


-Peter
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Getting localized NSPredicateEditor

2008-10-28 Thread Markus Spoettl

On Oct 28, 2008, at 3:57 PM, Peter Ammon wrote:
Here's something that may help - there's a method on NSRuleEditor: - 
(NSData *)_generateFormattingDictionaryStringsFile.  It gives you a  
strings file (as UTF16 data) appropriate for that control - write  
the data to a .strings file and then you can start translating it.


That method should never be called in production code but it can be  
useful for generating the strings file.



Excellent, that saves a lot of error prone work - I have more than 180  
such sentences. Thanks again!


Regards
Markus
--
__
Markus Spoettl



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]