We're sorry Aspose doesn't work properply without JavaScript enabled.

# Setting LocaleId For Existing Document

Problem: Users in Germany are setting dates as “5-Mai-2010”. Before we process the document, we’d like to change the language setting so that the dates show as “5-May-2010”. What is the best way to accomplish this?

This message was posted using Page2Forum from How-to: Detect the File Format - Aspose.Words for .NET and Java

Hi

Thanks for your inquiry. You can achieve this using DocuemntVisitor. Please see the following code example:

Document doc = new Document(@"Test001\in.doc");
LocaleChanger changer = new LocaleChanger(1033);
doc.Accept(changer);
doc.Save(@"Test001\out.doc");


LocaleChanger class is attached.

Best regards.

Thanks for your quick response and the LocaleChanger code. Unfortunately, I can’t get it to work. The code runs fine, but the date continue to be displayed as “5-Mai-2010” vs. their English (US) equivalent.

Attached is (some of) the document I’m trying to process. Maybe you will have more luck.

Hi Lois,

The code that Alexey posted appears to work for a simple example using regular fields but not for the Word 2003 FORMTEXT fields like those that are included in your document.

Unless one of my colleagues has any other ideas on the matter I think you will have to use a work around.

I am aware that the document is locked, but if you are able to change the contents of the template, and if it’s appropriate you might find updating those older fields to standard date fields would work.

If that’s not appropriate you could also programmatically search through the document using Regular expressions and convert any dates you find.

Thanks,