from Cura.util import resources
from Cura.util import version
- resources.setupLocalization() # it's important to set up localization at very beginning to install _
+ resources.setupLocalization(profile.getPreference('language')) # it's important to set up localization at very beginning to install _
#If we do not have preferences yet, try to load it from a previous Cura install
if profile.getMachineSetting('machine_type') == 'unknown':
from Cura.gui import configBase
from Cura.util import machineCom
from Cura.util import profile
+from Cura.util import resources
class preferencesDialog(wx.Dialog):
def __init__(self, parent):
for i in xrange(1, extruderCount):
configBase.SettingRow(left, 'model_colour%d' % (i+1), wx.Colour)
+ configBase.TitleRow(left, _("Language"))
+ configBase.SettingRow(left, 'language', map(lambda n: n[1], resources.getLanguageOptions()))
+
configBase.TitleRow(right, _("Filament settings"))
configBase.SettingRow(right, 'filament_physical_density')
configBase.SettingRow(right, 'filament_cost_kg')
#startPrintInterface is called from the main script when we want the printer interface to run in a separate process.
# It needs to run in a separate process, as any running python code blocks the GCode sender python code (http://wiki.python.org/moin/GlobalInterpreterLock).
app = wx.App(False)
- resources.setupLocalization()
+ resources.setupLocalization(profile.getPreference('language'))
printWindowHandle = printWindow()
printWindowHandle.Show(True)
printWindowHandle.Raise()
setting('submit_slice_information', 'False', bool, 'preference', 'hidden').setLabel(_("Send usage statistics"), _("Submit anonymous usage information to improve next 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('active_machine', '0', int, 'preference', 'hidden')
setting('model_colour', '#FFC924', str, 'preference', 'hidden').setLabel(_('Model colour'))
def getPathForFirmware(name):
return getPathForResource(resourceBasePath, 'firmware', name)
-def setupLocalization():
+def setupLocalization(selectedLanguage = None):
try:
if sys.platform.startswith('darwin'):
languages = NSLocale.preferredLanguages()
except Exception as e:
languages = ['en']
- languages = ['nl']
+ if selectedLanguage is not None:
+ for item in getLanguageOptions():
+ if item[1] == selectedLanguage:
+ languages = [item[0]] + languages
+
locale_path = os.path.normpath(os.path.join(resourceBasePath, 'locale'))
translation = gettext.translation('Cura', locale_path, languages, fallback=True)
translation.install(unicode=True)
+
+def getLanguageOptions():
+ return [
+ ['en', 'English'],
+ ['de', 'Deutsch'],
+ ['nl', 'Nederlands'],
+ ]