A Language object controls and collects together various related settings like spelling dictionaries and secondary fonts. Generally languages are applied to bits of text in a document by the user and should be considered just as other textual attribute (eg: font or color).
Note: languages are never determined by the characters (Unicode code points) they are applied to. The letter “e” could just as easily appear in English text as it could in German text. A language attribute is always the result of an explicit assignment of a language to a particular piece of text.
Language Type Commands
Language.systemLanguage v1.2
Returns the Language object the user has chosen as default in their Apple system preferences.
Language.languageWithCode codeString v1.2
Returns the Language object that has the given string for its code property (see below), or the @undefined value if no such language exists.
Language.enabledLanguages v1.2
Returns an array of all Language objects the user has enabled in their Nisus Writer preferences.
Language.allLanguages v1.2
Returns an array of all Language objects registered with Nisus Writer, including those that are currently disabled (eg: not shown in the menus).
Language Object Properties
.code v1.2
A string that uniquely identifies the language, read-only. The code itself is two letters as specified by ISO-639-1, eg: “de” for German, “el” for Greek, etc.
Some language codes may include a region modifier that will always be prefixed by an underscore, eg: “en_US” for American English and “en_GB” for British English.
User created languages, and other custom languages like Tech (Email), will have a code that starts with “X-” followed by the name of the language, eg: “X-TechEmail”.
.name v1.2
The localized name of the language, as it would be displayed to the user. Read-only.
.unlocalizedName v1.2
The unlocalized English name of the language. Read-only.
.isSpellCheckEnabled v1.3
Returns @true if the language has a spelling dictionary set, otherwise @false. Read-only.
.isUserCreated v1.2
Returns @true if the language was created by the user as a custom language or @false if the language is built into Nisus Writer. Read-only.
Language Object Commands
.apply v1.2
Applies the language to the currently selected text in the active document.
.learnSpelling word v1.3
Adds the given word to the list of words known to the spelling dictionary set for this language. If no spelling dictionary is set for the language, this command has no effect.
.forgetSpelling word v1.3
Removes the given word from the list of words known to the spelling dictionary set for this language. If the word is part of the dictionary’s built-in repertoire, removal may not be possible and behavior is dependent on the vendor. If no spelling dictionary is set for the language, or the word is not known to the dictionary, this command has no effect.
.spellingSuggestionsForWord word v2.0
Returns an array of spelling suggestions (eg: guesses at the correct spelling) for the given misspelled word. If the word is not misspelled, returns the @undefined value. If the word is misspelled, but there are no suggestions, returns an empty array.
Language Object Example
The following example applies the system language to all text in the active document:
Select All
$lang = Language.systemLanguage
$lang.apply
Previous Chapter Font Object |
<< index >> |
Next Chapter Range Object |