FieldLocaleId Property

Gets or sets the LCID of the field.

Namespace:  Aspose.Words.Fields
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.8.0


public int LocaleId { get; set; }

Property Value

Type: Int32


Shows how to insert a field and work with its locale.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert a DATE field and print the date it will display, formatted according to your thread's current culture
Field field = builder.InsertField(@"DATE");
Console.WriteLine($"Today's date, as displayed in the \"{CultureInfo.CurrentCulture.EnglishName}\" culture: {field.Result}");

Assert.AreEqual(1033, field.LocaleId);

// We can get the field to display a date in a different format if we change the current thread's culture
// If we want to avoid making such an all encompassing change,
// we can set this option to get the document's fields to get their culture from themselves
// Then, we can change a field's LocaleId and it will display its result in any culture we choose
doc.FieldOptions.FieldUpdateCultureSource = FieldUpdateCultureSource.FieldCode;
CultureInfo de = new CultureInfo("de-DE");
field.LocaleId = de.LCID;

Console.WriteLine($"Today's date, as displayed according to the \"{CultureInfo.GetCultureInfo(field.LocaleId).EnglishName}\" culture: {field.Result}");

See Also