Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Programatically changing the spelling language



Sorry I think I was just too tired to see the obvious ;-)
You're right it is just there in the Documentation... I'm really embarrassed about my question.

But there still seems to be no way to find out which languages are available for spell checking.
If you write a custom spell checker you use instantiate a NSSpellServer object where you register languages by name and vendor.
Just like "English (Apple)" you could add "English (Acme)" (just like the example in the NSSpellServer docu) but how can you distinguish later between the two vendors?

The API of NSSpellChecker has those methods to get and set the current language used for spell checking: "- (NSString*) lanugage" and "- (void) setLanguage:(NSString*)langName" which only use the language name but no vendor information...
From Cocoa's spell panel you could choose between Apple's and Acme's English spell checker but you can't do that with the publich APIs provided by Cocoa.

So what I'd like to see in a future version of Cocoa is an extension to NSSpellCheckers API:

- (NSDicionary*) availableLanugages;

returns a NSDicionary keys: language Names, values are NSArrays with wendor names:

Example:
{
"English" = ("Apple", "Acme", "ObjectFarm");
"German" = ("ObjectFarm");
}

-(NSDictionary*) languageWithVendor;

returns for example:
{
"language" = "Englsih";
"vendor" ="Apple";
}

- (void) setLanguage:(NSString*)name ofVendor:(NSString*)vendor;

Or something like that. Would be nice to have just in case more spell checkers emerge over time.

Currently I use a category to NSSpellChecker that uses the private variable _lanugagePopUp to extract language and vendor information but this an ugly hack of course.

This way I managed to a bundle that remembers the selected spell language for each Cocoa app when quitting and restores this setting when the app launches again. In addition it installs a Languages submenu in NSTextView's Spelling context menu to allow faster switching between languages. For the above example of two vendors with the same language name it is impossible to distinguish between them.

Any comments are welcome.

-Stefan



On Tuesday, November 27, 2001, at 12:24 AM, Ulrich Kortenkamp wrote:

Am Montag den, 26. November 2001, um 10:05, schrieb Stefan Kreutter:

Maybe I'm blind but I can't find a way to change the current spelling language.

Stefan,

first thank you for your ispell spelling service, which is exactly what I was looking for a week ago.

Second: there is a method called setLanguage in NSSpellChecker, which should do what you want.

Thanks again,

Ulli

[from the AppKit Java Docs:]

setLanguage

public boolean setLanguage(String language)

Sets the language to use in spell-checking to language. Returns whether the Language pop-up list in the Spelling panel lists language.
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev


References: 
 >Re: Programatically changing the spelling language (From: Ulrich Kortenkamp <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.