Set language of an epub file

I am using Aspose.Words to create text documents which I then export as PDF and ePUB files. Now I am trying to set the language metadata of the ePUB file. I tried the following:

var builtInProps = document.BuiltInDocumentProperties;
builtInProps["Language"].Value = documentLanguage;

What I want is that in the *.opf file within the ePUB-File the <dc:language>en-US</dc:language> should get set accordingly. But no matter what I set above, the language in the ePUB file is always “en-US”.

Moreover I use the following save options when saving the ePUB file:

var saveOptions = new HtmlSaveOptions(SaveFormat.Epub);

saveOptions.DocumentSplitCriteria = DocumentSplitCriteria.HeadingParagraph;
saveOptions.DocumentSplitHeadingLevel = 1;
saveOptions.EpubNavigationMapLevel = 1;
saveOptions.ExportDocumentProperties = true;
saveOptions.UpdateCreatedTimeProperty = true;
saveOptions.UpdateLastSavedTimeProperty = true;

The Update...Property properties have the effect that the respective timestamps are being set in the epub file. But the ExportDocumentProperties seems to have no effect at all.

What can I do?

@eexperts Aspose.Words determines language that should be written to EPUB by the locale ID set in the document’s Normal style. So in your case you can use code like this to set the required language:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder();
builder.Write("Hello, Aspose.Words!!!");

// Aspose.Words determines language of the document by the localeId in normal style.
doc.Styles[StyleIdentifier.Normal].Font.LocaleId = new System.Globalization.CultureInfo("uk-UA", false).LCID;

doc.Save("C:\\Temp\\out.epub");
1 Like

That worked seamlessly. Thank you for the hint!

1 Like