[Tex/LaTex] Spellchecking two languages with TeXstudio

languagestexstudio

I'm writing in TeXstudio, using Spanish and English. I first loaded the babel package, and then used \selectlanguage within the text. In Options / Configure TeXstudio, I have selected Spanish as default language. This causes all text in English to be underlined in red (the program 'thinks' all the words are misspelled because they're in a language it didn't expect).
Changing the default language to English makes the red underlining appear in the Spanish text instead.
Here's the code used:

\documentclass[]{article}

\usepackage[utf8]{inputenc}
\usepackage[spanish,english]{babel} 

\begin{document}

\section{Primera parte}
\selectlanguage{english}
This section is written in English. %This is all underlined in red

\section{Segunda parte}
\selectlanguage{spanish}
Esta sección está escrita en español. 

\end{document}

Am I missing something really obvious here? I did try the 'Import dictionary' option.

Best Answer

Sometimes, the multilingual parts are cleanly separated, e.g. in a thesis where front-sheet and abstract are required in the universities native language, while the text can be in English. Or, as given in the original question, they are separate sections.

In such cases, the simplest option might be to split the document into \include or \input files, in such a manner, that each file contains only a single language.

TeXStudio then supports a "magic comment", that declares the spellchecker for a given file and can be added by the program itself, by clicking the language button in the status bar, which offers "insert language as TeX comment".