chiark / gitweb /
Add language selection.
authordaid <daid303@gmail.com>
Tue, 1 Oct 2013 14:02:46 +0000 (16:02 +0200)
committerdaid <daid303@gmail.com>
Tue, 1 Oct 2013 14:02:46 +0000 (16:02 +0200)
Cura/gui/app.py
Cura/gui/preferencesDialog.py
Cura/gui/printWindow.py
Cura/util/profile.py
Cura/util/resources.py

index 3ef52ba21cbf6251209a2881d6471caeaf9b11eb..3861dbc14d6efd13de58722d8683b61997c421c5 100644 (file)
@@ -45,7 +45,7 @@ class CuraApp(wx.App):
                from Cura.util import resources
                from Cura.util import version
 
                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':
 
                #If we do not have preferences yet, try to load it from a previous Cura install
                if profile.getMachineSetting('machine_type') == 'unknown':
index fd587892bb3661926865e2647ab94001a5d95ba6..8dc0199d0a1f23774db7593944b8b77af58b9300 100644 (file)
@@ -7,6 +7,7 @@ from Cura.gui import configWizard
 from Cura.gui import configBase
 from Cura.util import machineCom
 from Cura.util import profile
 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):
 
 class preferencesDialog(wx.Dialog):
        def __init__(self, parent):
@@ -26,6 +27,9 @@ class preferencesDialog(wx.Dialog):
                for i in xrange(1, extruderCount):
                        configBase.SettingRow(left, 'model_colour%d' % (i+1), wx.Colour)
 
                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')
                configBase.TitleRow(right, _("Filament settings"))
                configBase.SettingRow(right, 'filament_physical_density')
                configBase.SettingRow(right, 'filament_cost_kg')
index 8e2d240592039566275a81937152e30a64418ceb..1e4ee6f4358b6b76f5c4dee9033da05136fdfcf9 100644 (file)
@@ -91,7 +91,7 @@ def startPrintInterface(filename):
        #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)
        #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()
        printWindowHandle = printWindow()
        printWindowHandle.Show(True)
        printWindowHandle.Raise()
index 4dbe4c2aeee1d37910438dc3420ecfd6f6a9edf9..679b89140d0f5f5b6cb597dbdd060cf9a0ba9fb8 100644 (file)
@@ -343,6 +343,7 @@ setting('check_for_updates', 'True', bool, 'preference', 'hidden').setLabel(_("C
 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('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'))
 setting('active_machine', '0', int, 'preference', 'hidden')
 
 setting('model_colour', '#FFC924', str, 'preference', 'hidden').setLabel(_('Model colour'))
index e071e419ff9b2391e0101407697f50c54b576891..8dbe9bd1e719dab4064f598a6b50ce4492bdf547 100644 (file)
@@ -44,7 +44,7 @@ def getPathForMesh(name):
 def getPathForFirmware(name):
        return getPathForResource(resourceBasePath, 'firmware', name)
 
 def getPathForFirmware(name):
        return getPathForResource(resourceBasePath, 'firmware', name)
 
-def setupLocalization():
+def setupLocalization(selectedLanguage = None):
        try:
                if sys.platform.startswith('darwin'):
                        languages = NSLocale.preferredLanguages()
        try:
                if sys.platform.startswith('darwin'):
                        languages = NSLocale.preferredLanguages()
@@ -54,7 +54,18 @@ def setupLocalization():
        except Exception as e:
                languages = ['en']
 
        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)
        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'],
+       ]