TX Spell .NET for WPF

Right-to-Left Languages

Topic

Arabic, Hebrew, Persian and Urdu are written from right to left, and TX Spell .NET checks them like any other language. Their dictionaries are Hunspell dictionaries, loaded with the same code, and a text that mixes them with English is checked in one pass. What is different is on the editor's side: TX Text Control lays out the paragraphs from right to left. Support for right-to-left dictionaries was added in TX Spell .NET 4.0.

Dictionaries for Right-to-Left Languages

Text Control offers these right-to-left dictionaries on the dictionary download page:

LanguageArchiveDictionary fileAlso contains
Arabicdictionary.ar.zipar.dicA thesaurus
Arabicdictionary.ar_AR.zipar.dicNothing else
Hebrewdictionary.he_IL.ziphe_IL.dicNothing else
Persiandictionary.fa_IR.zipfa.dicNothing else
Urdudictionary.ur_PK.zipur.dicNothing else

The two Arabic archives contain different dictionaries with the same file name, ar.dic, so only one of them can be in the dictionary folder. dictionary.ar.zip is the newer one and brings a thesaurus. None of the right-to-left archives contains a hyphenation list. Hunspell and OpenOffice Dictionaries shows where the files go.

Check Right-to-Left Text

Load the dictionary with its file name, as for any language:

// Check Hebrew text in addition to English
txSpellChecker1.Dictionaries.Add(new TXTextControl.Proofing.OpenOfficeDictionary("he_IL.dic"));

Loaded from the default folder, the dictionary gets its language from the file name, here Hebrew (Israel), and the spell checker uses it for the Hebrew words of a document. No setting for the writing direction is needed. A text that mixes directions is checked in one call: in a test with the English and the Hebrew dictionary loaded, the text Hello שלום wrold עולוםם returned one misspelled English and one misspelled Hebrew word.

Suggestions work the same way: for the misspelled Arabic word المدرسسة, the first suggestion is المدرسة.

Right-to-Left Text in TX Text Control

TX Text Control writes and shows right-to-left text in its paragraphs. Arabic text in a right-to-left paragraph, with a misspelled word underlined, its suggestions in the context menu and the Spelling dialog:

TX Text Control Words with an Arabic document: the Spelling dialog shows Misspelled word - Language: Arabic (Saudi Arabia), the misspelled word in red, Arabic suggestions and the Suggestions Dictionary ar.dic, and the context menu of the word lists Arabic suggestions, Ignore, Ignore All, Add To Dictionary, Spell Check Dialog and Options. The status bar shows Arabic (Saudi Arabia).

These members of TX Text Control set the writing direction:

MemberDoes
ParagraphFormat.DirectionSets a paragraph to Direction LeftToRight or RightToLeft
Selection.ChangeDirectionSwitches the direction of the selected paragraphs, and swaps their left and right alignment and tabs
InputFormat.RightToLeftGets or sets the direction at the input position

The screenshot shows the Left to Right and Right to Left buttons of an earlier ribbon of TX Text Control Words.

Language Detection and Right-to-Left Text

Of the right-to-left languages, language detection recognizes Arabic by default. Hebrew (he), Persian (fa) and Urdu (ur) can be added to DetectableLanguageScopes; without them, a Hebrew sentence gets no language. Language Detection describes the list.

Next Steps