How do I set the complied docx's language?

js
jstovell
Posts: 22
Joined: Mon Apr 15, 2013 12:56 am
Platform: Mac

Mon Apr 15, 2013 1:24 am Post

I have my Mac configured to use Canadian English as my primary language, and thus Scrivener uses that as my composition language, just as expected. The documents I write are mostly in Canadian English and also use other languages as well. It all works nicely within Scrivener.

However, when I compile my documents into .docx files and open them in Word, all the text in the document has its language set to "English (UK)" rather than "English (CAN)" and the various other language codes as appropriate for a given bit of text. Now, if my document was written in nothing but English, I'd just use a couple of mouse clicks to switch the language for all the text in the document to "English (CAN)" and be done with it. But since I use multiple languages, I end up needing to go through the whole document and find every instance of every language and set it to the correct one. This, of course, is rather frustrating and time-consuming, but for my purposes I can't just leave it with the incorrect language assigned to it, so I have to waste the effort.

So, what I am wondering is whether there is any way to get Scrivener to preserve the correct language for any given block of text when compiling a .docx file?

User avatar
KB
Site Admin
Posts: 20775
Joined: Tue Jun 13, 2006 11:23 pm
Platform: Mac
Location: Truro, Cornwall
Contact:

Mon Apr 15, 2013 9:26 am Post

There's no way in Scrivener for one block of text to have a different language assigned to it to another block of text, as Scrivener uses the standard OS X text system which doesn't allow for this. It's strange that the language is coming out as UK English in your .docx document, though. Internally, to generate .docx documents, Scrivener generates an RTF document and then converts it to .docx using a third-party converter, but the RTF generated again uses Apple's text system which should produce the most appropriate language. If you go into Edit > Spelling and Grammar > Show Spelling and Grammar, what language is set there? My guess is that it is "Automatic By Language", which allows OS X to guess which language you are writing as you go along (rather than forcing the entire document to one language). My guess is that when the RTF document is created, because it's set to "Automatic By Language", no language is explicitly set, so the OS X text system probably examines the text and guesses that the language is UK English (based on the similar spellings).

To test this out, could you please open TextEdit, copy and paste a swathe of text from Scrivener into it, save the document in TextEdit as RTF, and open that in Word - do you see the same behaviour?

All the best,
Keith
"You can't waltz in here, use my toaster, and start spouting universal truths without qualification."

js
jstovell
Posts: 22
Joined: Mon Apr 15, 2013 12:56 am
Platform: Mac

Mon Apr 15, 2013 5:59 pm Post

Hi Keith,

Too bad about the individual text blocks, but oh well. Thanks anyway. :)

Based on your suggestion, I just ran a series of tests that I hope will be helpful. For all tests, I used the same individual document within my Scrivener project (or the text from it when creating RTFs via TextEdit). The result is the language of the document when I open it Word 2011.

Code: Select all

Method of         |  Doc/docx    |  Spelling language |  Result in Word
generation        |  converter   |  setting           |
-------------------------------------------------------------------------

RTF via TextEdit  |  N/A         |  Automatic         |  English (US)
RTF via TextEdit  |  N/A         |  Canadian English  |  English (US)

DOC via TextEdit  |  N/A         |  Automatic         |  English (US)
DOC via TextEdit  |  N/A         |  Canadian English  |  English (US)

DOCX via TextEdit |  N/A         |  Automatic         |  English (UK)
DOCX via TextEdit |  N/A         |  Canadian English  |  English (UK)

Compiled to RTF   |  N/A         |  Automatic         |  English (US)
Compiled to RTF   |  N/A         |  Canadian English  |  English (US)

Compiled to DOC   |  Java-based  |  Automatic         |  English (UK)
Compiled to DOC   |  Java-based  |  Canadian English  |  English (UK)
Compiled to DOC   |  Standard    |  Automatic         |  English (US)
Compiled to DOC   |  Standard    |  Canadian English  |  English (US)

Compiled to DOCX  |  Java-based  |  Automatic         |  English (UK)
Compiled to DOCX  |  Java-based  |  Canadian English  |  Englist (UK)
Compiled to DOCX  |  Standard    |  Automatic         |  English (UK)
Compiled to DOCX  |  Standard    |  Canadian English  |  English (UK)


By the look of it, it seems that (at least on my computer):
  1. the language specified in the Spelling settings in Scrivener and/or TextEdit make no difference,
  2. RTF files always end up in American English no matter what software is used to create them,
  3. DOCX files always end up in British English no matter what software is used to create them,
  4. DOC files compiled by Scrivener using the standard converter end up in American English, but
  5. DOC files compiled by Scrivener using the Java-based converter end up in British English.

So, the only thing that appears to make any difference in the process is if I use the Java-based converter to compile to DOC. So what I am wondering now is whether it would be possible to coerce the Java-based converter into setting a specific language for the document when I compile.
Last edited by jstovell on Mon Apr 15, 2013 6:08 pm, edited 1 time in total.

js
jstovell
Posts: 22
Joined: Mon Apr 15, 2013 12:56 am
Platform: Mac

Mon Apr 15, 2013 6:04 pm Post

Actually, on second thought, there probably isn't any reason to bother. Since at best we could only specify the default language for the whole document, I can just do that with a few clicks of the mouse in Word already. The tedious part is apparently beyond help anyway. :(

Oh well. Thanks anyway, Keith. I do love using Scrivener, by the way. Great software! :D

User avatar
xiamenese
Posts: 4419
Joined: Mon Jan 29, 2007 1:32 am
Platform: Mac
Location: London or Exeter, UK.

Wed Apr 17, 2013 1:53 am Post

My Mac uses British English, so my language in Scrivener is British English. I don't use Word, but Nisus Writer Pro, and it's possible that that makes a difference, but:

1) When I export .rtf from Scrivener and open it in NWP, the document is marked as being in British English and the spell check behaves accordingly. Clearly, to me, if Word would not do likewise, I would assume it to be an issue with Word, rather than with the Scrivener .rtf exporter;

2) The non-Java .doc export, is in fact .rtf with a changed creator code and extension, which is legal with Word (but can cause problems if you attach the file to an email that a Windows user then forwards to another recipient)**;

3) I too use mixed language documents, though in my case normally English and Chinese. As my documents are generally fairly short, not full-length books or articles running into thousands of words, I generally mark the Chinese in NWP by hand. Were I to need to do it with a long document, I'd do it using "Search and Replace", which in my case would be easy as I could simply search for any text in the Chinese font and mark that as Chinese. Between English and French, I would have to be more ruseful, so in Scrivener, either I would use a different font/size/style as necessary for French — using a preset for full paragraphs — that I could then have the Search look for and then Replace it marking the language as French and putting the text into the standard font, etc., or I would mark each stretch in French with a [fr] … [/fr], so S&R could look for those tags with the text in between, delete the tags and mark the text as French. I presume Word can do the same as NWP through Search and Replace.

Mark

EDIT: ** so of course, the .doc that results will behave like the .rtf export from the point of view of your test.
The Scrivenato sometimes known as Mr X.
iMac 27" (late 2015) 10.15.6, 24GB RAM, 512GB SSID
MBP17" (late 2011) 10.13.6, 16GB RAM, 2TB SSID
2017 iPad, iPadOS 14, 128GB, Apple Pencil
Scrivener, Scapple, Nisus Writer Pro, Bookends …