We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Localization

Hello,

how can I set the localization for a saved Word-Doc with DOCIO. FYI: I have 2 Word-Docs, that are copied together. Both are set to my natural language german. But when I save the generated file it is set to english. Of course Words AutoCorrect says a million errors. Can someone help please?

5 Replies

VR Vijay Ramachandran Syncfusion Team May 31, 2017 06:39 AM UTC

Hi Carsten,

Thank you for using Syncfusion products.

DocIO preserve the language settings as it is the input Word document while resaving the Word document.
If your requirement is set specific language for a Word document means, then you can achieve this by using WCharacterFormat.LocaleIdASCII API. Please find the example code snippet to set LocalIdASCII from below: 
           //Creates new Word document.
            WordDocument wordDocument = new WordDocument();
           
//This method adds a section and a paragraph.
            wordDocument.EnsureMinimal();
           
//Appends the contents into the paragraph
            wordDocument.LastParagraph.AppendText("Dieses Word-Dokument wurde mit Syncfusion Essential DocIO erstellt.");
           
//Sets language (German) for particular paragraph
            //You can also set language for each test ranges.
            wordDocument.LastParagraph.BreakCharacterFormat.LocaleIdASCII = (short)LocaleIDs.de_DE;
           
//Save as DOCX format.
            wordDocument.Save("Sample.docx", FormatType.Docx);
           
//Close document.
            wordDocument.Close(); 

If you are facing any issue while resaving the Word document, then kindly provide us following details. Thereby we will analyze further and provide you the solution at the earliest.

     1. Input and output Word documents along with code snippet or sample.
     2. System culture information.
     3. Microsoft Word application Version.
     4. Operating System.

Let us know if you have any concern.

Regards,
Vijay R
 



CW Carsten Wuttke May 31, 2017 06:52 AM UTC

Thanks Vijay. That one line for each paragraph in my doc did the trick.
Even I was wondering as you say "It should preserve the language"...I take a doc in german and copy the german header and footer from another one into it and the paragraphs are english... Weird. OK. Can perhaps even depend on my word 2016 ;-) My Windows 10-Language is german.


VR Vijay Ramachandran Syncfusion Team May 31, 2017 11:29 AM UTC

Hi Carsten,

Thank you for your update.

Regarding query “I take a doc in german and copy the german header and footer from another one into it and the paragraphs are English”:

Kindly let us know your confirmation on whether you have done this operation (copy & paste) using Microsoft Word application or by using DocIO. Also, provide us the input and output documents along with code snippet (if anything) which you tried at your end.

Additional information about Language LocaleIDs:

When paragraph has multiple text range with different language text then, we need to set LocaleIDs for each text range. Please find the code snippet from below:
 
           //Creates new Word document.
            WordDocument wordDocument = new WordDocument();
           
//This method adds a section and a paragraph in the
            wordDocument.EnsureMinimal();
           
//Sets language for particular paragraph
            wordDocument.LastParagraph.BreakCharacterFormat.LocaleIdASCII = (short)LocaleIDs.de_DE;
            
//Appends the contents into the paragraph
            IWTextRange textRange = wordDocument.LastParagraph.AppendText("Dieses Word-Dokument wurde mit Syncfusion Essential DocIO erstellt. ");
           
//Sets language for particular text range.
            textRange.CharacterFormat.LocaleIdASCII = (short)LocaleIDs.de_DE;
           
textRange = wordDocument.LastParagraph.AppendText("This Word document was created using Syncfusion Essential DocIO.");
           
//Sets language for particular text range.
            textRange.CharacterFormat.LocaleIdASCII = (short)LocaleIDs.en_US;
            //Save as DOCX format.
            wordDocument.Save("Sample.docx", FormatType.Docx);
           
//Close document.
            wordDocument.Close(); 

Let us know if you have any concern.

Regards,
Vijay R
 



CW Carsten Wuttke May 31, 2017 02:21 PM UTC

As snippets it would be multiple parts. And I can think of the problem so after all:The process is: I load a word with docio into RTE. Then the user could edit - if he wishes - and then he clicks download. Then a NEW (and thats I bet the problem) docio is generated and the headers from another word are copied to the NEW one. Sorry Vijay. Didn't think of that edit and then new step previously. So it makes sense that it comes out english as Syncfusion is english.Edit:Sorry again. Screamed to early. Here is my copiing of the header and footer-code:foreach (WSection section in document.Sections)        {                 foreach (TextBodyItem item in d2.Sections[0].HeadersFooters.Header.ChildEntities)            {          section.HeadersFooters.Header.ChildEntities.Add(item.Clone());                                 }                 foreach (TextBodyItem item in d2.Sections[0].HeadersFooters.Footer.ChildEntities)            {          section.HeadersFooters.Footer.ChildEntities.Add(item.Clone());                 }                 foreach(WParagraph p in section.Paragraphs) p.BreakCharacterFormat.LocaleIdASCII = (short)LocaleIDs.de_DE;        }you see the bold line, where it should set every paragraph to german. But: It says english (USA) in AutoCorrection. *sigh*


VR Vijay Ramachandran Syncfusion Team June 1, 2017 01:21 PM UTC

Hi Carsten,

Thank you for using Syncfusion products.

A support incident to track the status of your query has been created under your account. Please log on to our support website to check for further updates,

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents

Please let us know if you have any concern.

Regards,
Vijay R


Loader.
Up arrow icon