Sometimes in word files, we type another language rather than default, and need spellers and other proofing tools adjust to the language we typed.
This article is talking about how to alter language dictionary as non-default language via Spire.Doc. Here take English as default language and alter to Spanish in Peru as an example.
As for more language information, refer this Link to Microsoft Locale ID Values.
Here are the steps:
Step 1: Create a new word document.
Document document = new Document();
Step 2: Add new section and paragraph to the document.
Section sec = document.AddSection(); Paragraph para = sec.AddParagraph();
Step 3: Add a textRange for the paragraph and append some Peru Spanish words.
TextRange txtRange = para.AppendText("corrige según diccionario en inglés"); txtRange.CharacterFormat.LocaleIdASCII = 10250;
Step 4: Save and review.
document.SaveToFile("result.docx", FileFormat.Docx2013); System.Diagnostics.Process.Start("result.docx");
Here is the result screenshot.
Full Code:
using Spire.Doc.Documents; using Spire.Doc.Fields; namespace AlterLang { class Program { static void Main(string[] args) { Document document = new Document(); Section sec = document.AddSection(); Paragraph para = sec.AddParagraph(); TextRange txtRange = para.AppendText("corrige según diccionario en inglés"); txtRange.CharacterFormat.LocaleIdASCII = 10250; document.SaveToFile("result.docx", FileFormat.Docx2013); System.Diagnostics.Process.Start("result.docx"); } } }