Categories > OpenTBS with DOCX >

Change default language in DOCX templates

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Osof
Date: 2017-03-22
Time: 09:51

Change default language in DOCX templates

Hello. Can someone help me to change default language for templates? I use OpenTBS and it makes files on French by default. My spellchecker goes crazy about this. I set another language for all template in MS Word but its doesn't works. Thanks for help!
By: Skrol29
Date: 2017-03-25
Time: 23:39

Re: Change default language in DOCX templates

Hi Osof,

OpenTBS does not turn language into French, or other language.
But is does delete all language definition when a sub-file is opened. This is because the spell checking can split TBS tags in several parts.

Generally, a DOCX has only one default language defined in the root style of the document, wich is stored in the sub-file "word/styles.xml".
But in fact you can define a different language for any custom style.
In addition to the language defined in styles, you can also define a custom language for any piece of text in the document.

What is probably happening to your document is that all custom language elements are deleted by OpenTBS in the main document, and then the default language (French I guess) steel remains in the default style because "word/styles.xml" is not modified.

In order to force the default language in the root style, here is the code (example to force language to English US):
$TBS->PlugIn(OPENTBS_EDIT_ENTITY, 'word/styles.xml', 'w:styles/w:docDefaults/w:rPrDefault/w:lang', 'w:val', 'en-US', true);