Repository: spyder-ide/spyder

Issue:
Error when changing language from French to English
## Description

### What steps will reproduce the problem?

<!--- You can use Markdown here --->

Language changed from French to English, in the tools tab, Spyder poped up a troubleshooting.

### Traceback
```python-traceback
  File "C:\Users\nhassen\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder\plugins\configdialog.py", line 224, in button_clicked
    configpage.apply_changes()
  File "C:\Users\nhassen\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder\plugins\configdialog.py", line 113, in apply_changes
    self._save_lang()
  File "C:\Users\nhassen\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder\plugins\configdialog.py", line 1138, in _save_lang
    save_lang_conf(value)
  File "C:\Users\nhassen\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder\config\base.py", line 346, in save_lang_conf
    with open(LANG_FILE, 'w') as f:
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\nhassen\\.spyder-py3\\langconfig'
```

## Versions

* Spyder version: 3.3.1 
* Python version: 3.7.0
* Qt version: 5.9.6
* PyQt5 version: 5.9.2
* Operating System: Windows 10

### Dependencies

```
pyflakes >=0.6.0  :  2.0.0 (OK)
pycodestyle >=2.3 :  2.4.0 (OK)
pygments >=2.0    :  2.2.0 (OK)
sphinx >=0.6.6    :  1.7.9 (OK)
rope >=0.9.4      :  0.11.0 (OK)
jedi >=0.9.0      :  0.12.1 (OK)
nbconvert >=4.0   :  5.4.0 (OK)
pandas >=0.13.1   :  0.23.4 (OK)
numpy >=1.7       :  1.15.1 (OK)
sympy >=0.7.3     :  1.1.1 (OK)
cython >=0.21     :  0.28.5 (OK)
qtconsole >=4.2.0 :  4.4.1 (OK)
IPython >=4.0     :  6.5.0 (OK)
matplotlib >=2.0.0:  2.2.3 (OK)
pylint >=0.25     :  2.1.1 (OK)
```



Discussion:
> PermissionError: [Errno 13] Permission denied: 'C:\\Users\\nhassen\\.spyder-py3\\langconfig'

This means that you don't have permissions to write on that file. I don't know how you ended up in that situation (probably because you ran Spyder as admin in your own account), but you need to restore the right permissions to avoid this error.

We'll show an error message informing users when an error occurs during this operation.

Resolving patch:
diff --git a/spyder/plugins/configdialog.py b/spyder/plugins/configdialog.py
--- a/spyder/plugins/configdialog.py
+++ b/spyder/plugins/configdialog.py
@@ -10,6 +10,7 @@
 
 # Standard library imports
 import os.path as osp
+import traceback
 
 # Third party imports
 from qtpy import API
@@ -1147,8 +1148,16 @@ def _save_lang(self):
                 data = combobox.itemData(combobox.currentIndex())
                 value = from_qvariant(data, to_text_string)
                 break
-        save_lang_conf(value)
-        self.set_option('interface_language', value)
+        try:
+            save_lang_conf(value)
+            self.set_option('interface_language', value)
+        except Exception:
+            QMessageBox.critical(self, _("Error"),
+                _("We're sorry but the following error occurred while trying "
+                  "to set your selected language:<br><br>"
+                  "<tt>{}</tt>").format(traceback.format_exc()),
+                QMessageBox.Ok)
+            return
 
 
 class ColorSchemeConfigPage(GeneralConfigPage):


Test patch: