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.
Unfortunately, activation email could not send to your email. Please try again.

Localization

Thread ID:

Created:

Updated:

Platform:

Replies:

130732 May 30,2017 02:57 AM Jun 1,2017 09:21 AM ASP.NET Web Forms 5
loading
Tags: DocIO
Carsten Wuttke
Asked On May 30, 2017 02:57 AM

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?

Vijay Ramachandran [Syncfusion]
Replied On May 31, 2017 02:39 AM

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
 


Carsten Wuttke
Replied On May 31, 2017 02:52 AM

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.

Vijay Ramachandran [Syncfusion]
Replied On May 31, 2017 07:29 AM

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
 


Carsten Wuttke
Replied On May 31, 2017 10:21 AM

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*

Vijay Ramachandran [Syncfusion]
Replied On June 1, 2017 09:21 AM

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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;