setting('submit_slice_information', 'False', bool, 'preference', 'hidden').setLabel(_("Send usage statistics"), _("Submit anonymous usage information to improve future versions of Cura"))
setting('youmagine_token', '', str, 'preference', 'hidden')
setting('filament_physical_density', '1240', float, 'preference', 'hidden').setRange(500.0, 3000.0).setLabel(_("Density (kg/m3)"), _("Weight of the filament per m3. Around 1240 for PLA. And around 1040 for ABS. This value is used to estimate the weight if the filament used for the print."))
-setting('language', 'English', str, 'preference', 'hidden').setLabel(_('Language'), _('Change the language in which Cura runs. Switching language requires a restart of Cura'))
+setting('language', 'AUTO', str, 'preference', 'hidden').setLabel(_('Language'), _('Change the language in which Cura runs. Switching language requires a restart of Cura'))
setting('active_machine', '0', int, 'preference', 'hidden')
setting('model_colour', '#C9E240', str, 'preference', 'hidden').setLabel(_('Model colour'), _('Display color for first extruder'))
import os
import sys
import glob
+import platform
+import locale
import gettext
#Default to english
languages = ['en']
- if selectedLanguage is not None:
+ if selectedLanguage is None or selectedLanguage == 'AUTO':
+ defaultLocale = getDefaultLocale()
+ if defaultLocale is not None:
+ for item in getLanguageOptions():
+ if item[0] is not None and defaultLocale.startswith(item[0]):
+ languages = [item[0]]
+ else:
for item in getLanguageOptions():
if item[1] == selectedLanguage and item[0] is not None:
languages = [item[0]]
# ['es', 'Spanish'],
# ['po', 'Polish']
]
+
+def getDefaultLocale():
+ defaultLocale = None
+
+ # On Windows, we look for the actual UI language, as someone could have
+ # an english windows but use a non-english locale.
+ if platform.system() == "Windows":
+ try:
+ import ctypes
+
+ windll = ctypes.windll.kernel32
+ defaultLocale = locale.windows_locale[windll.GetUserDefaultUILanguage()]
+ except:
+ pass
+
+ if defaultLocale is None:
+ try:
+ defaultLocale = locale.getdefaultlocale()[0]
+ except:
+ pass
+
+ return defaultLocale