## IHyphenationCallback.RequestDictionary method

Notifies application that hyphenation dictionary for the specified language wasn't found and may need to be registered.

Implementation should find a dictionary and register it using [`RegisterDictionary`](../../hyphenation/registerdictionary/) methods.

If dictionary is unavailable for the specified language implementation can opt out of further calls for the same language using [`RegisterDictionary`](../../hyphenation/registerdictionary/) with `null` value.

```csharp
public void RequestDictionary(string language)
```

| Parameter | Type | Description |
| --- | --- | --- |
| language | String | A language name, e.g. "en-US". See .NET documentation for "culture name" and RFC 4646 for details. |

## Remarks

Exceptions thrown by this method will abort execution of page layout process.

## Examples

Shows how to open and register a dictionary from a file.

```csharp
// Set up a callback that tracks warnings that occur during hyphenation dictionary registration.
WarningInfoCollection warningInfoCollection = new WarningInfoCollection();
Hyphenation.WarningCallback = warningInfoCollection;

// Register an English (US) hyphenation dictionary by stream.
Stream dictionaryStream = new FileStream(MyDir + "hyph_en_US.dic", FileMode.Open);
Hyphenation.RegisterDictionary("en-US", dictionaryStream);

Assert.That(warningInfoCollection.Count, Is.EqualTo(0));

// Open a document with a locale that Microsoft Word may not hyphenate on an English machine, such as German.
Document doc = new Document(MyDir + "German text.docx");

// To hyphenate that document upon saving, we need a hyphenation dictionary for the "de-CH" language code.
// This callback will handle the automatic request for that dictionary.
Hyphenation.Callback = new CustomHyphenationDictionaryRegister();

// When we save the document, German hyphenation will take effect.
doc.Save(ArtifactsDir + "Hyphenation.RegisterDictionary.pdf");

// This dictionary contains two identical patterns, which will trigger a warning.
Assert.That(warningInfoCollection.Count, Is.EqualTo(1));
Assert.That(warningInfoCollection[0].WarningType, Is.EqualTo(WarningType.MinorFormattingLoss));
Assert.That(warningInfoCollection[0].Source, Is.EqualTo(WarningSource.Layout));
Assert.That(warningInfoCollection[0].Description, Is.EqualTo("Hyphenation dictionary contains duplicate patterns. The only first found pattern will be used. " +
                "Content can be wrapped differently."));
```

Shows how to open and register a dictionary from a file (CustomHyphenationDictionaryRegister).

```csharp
/// <summary>
/// Associates ISO language codes with local system filenames for hyphenation dictionary files.
/// </summary>
private class CustomHyphenationDictionaryRegister : IHyphenationCallback
{
    public CustomHyphenationDictionaryRegister()
    {
        mHyphenationDictionaryFiles = new Dictionary<string, string>
        {
            { "en-US", MyDir + "hyph_en_US.dic" },
            { "de-CH", MyDir + "hyph_de_CH.dic" }
        };
    }

    public void RequestDictionary(string language)
    {
        Console.Write("Hyphenation dictionary requested: " + language);

        if (Hyphenation.IsDictionaryRegistered(language))
        {
            Console.WriteLine(", is already registered.");
            return;
        }

        if (mHyphenationDictionaryFiles.ContainsKey(language))
        {
            Hyphenation.RegisterDictionary(language, mHyphenationDictionaryFiles[language]);
            Console.WriteLine(", successfully registered.");
            return;
        }

        Console.WriteLine(", no respective dictionary file known by this Callback.");
    }

    private readonly Dictionary<string, string> mHyphenationDictionaryFiles;
}
```

### See Also

* interface [IHyphenationCallback](../)
* namespace [Aspose.Words](../../../aspose.words/)
* assembly [Aspose.Words](../../../)
