Hello, we are successfully proceeding with the software development project thanks to your product.
I’m inquiring because there was a bug related to aspose during the project.
We are using MS Word in South Korea. We produce MS Word documents using your product in Python language.
But here’s a problem. MS Word language default settings are in English, so all documents in South Korea are marked with grammar errors in red underscores.
I would appreciate it if you could tell me how to change the default language setting of MS Word in Aspose.
sincerely
@surro.clm If you are loading an existing document, you can specify language preferences in the LoadOptions.
If you are creating a document from scratch you can specify the locale id in the default font in StyleCollection.default_font using locale_id, locale_id_bi or locale_id_far_east properties. The same properties can be used if it is required to specify the language of an individual Run
node.
The values of locale Ids can be found here:
https://learn.microsoft.com/en-us/openspecs/office_standards/ms-oe376/6c085406-a698-4e12-9d4d-c3b0ee3dbc4a
Thank you for your answer.
I tried as you explained, but the following error occurs in the process of first generating the file instead of reading the existing file with aw.Document().
load_options = aw.loading.LoadOptions()
load_options.language_preferences.default_editing_language = 1042 # KOREAN
self.doc = aw.Document()
self.builder = aw.DocumentBuilder(self.doc)
TypeError: ['function takes at most 0 arguments (1 given)', "can't build String from 'aspose.words.loading.LoadOptions'", "can't build String from 'aspose.words.loading.LoadOptions'", "can't build Stream from 'aspose.words.loading.LoadOptions'", "can't build Stream from 'aspose.words.loading.LoadOptions'"]
@surro.clm Since you are creating document from scratch, you should specify default locale using StyleCollection.default_font. For example see the following code:
doc = aw.Document()
doc.styles.default_font.locale_id_far_east = 1042 # KOREAN
builder = aw.DocumentBuilder(doc)
builder.write("안녕하세요 세계!")
doc.save("C:\\Temp\\out.docx")
In the output document in document defaults eastAsia
language will be set to ko-KR
:
<w:rPrDefault>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:eastAsia="Times New Roman" w:hAnsi="Times New Roman" w:cs="Times New Roman" />
<w:lang w:val="en-US" w:eastAsia="ko-KR" w:bidi="ar-SA" />
</w:rPr>
</w:rPrDefault>
Oh… Thank you. Thank you. Thank you.
Thanks to you, I was able to solve the problem. Have a happy weekend.
1 Like