1 from __future__ import absolute_import
2 __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
10 if sys.platform.startswith('darwin'):
12 #Foundation import can crash on some MacOS installs
13 from Foundation import *
17 if sys.platform.startswith('darwin'):
18 if hasattr(sys, 'frozen'):
20 resourceBasePath = NSBundle.mainBundle().resourcePath()
22 resourceBasePath = os.path.join(os.path.dirname(__file__), "../../../../../")
24 resourceBasePath = os.path.join(os.path.dirname(__file__), "../resources")
26 if hasattr(sys, 'frozen'):
27 resourceBasePath = os.path.join(os.path.dirname(__file__), "../../resources")
29 resourceBasePath = os.path.join(os.path.dirname(__file__), "../resources")
31 def getPathForResource(dir, subdir, resource_name):
32 assert os.path.isdir(dir), "{p} is not a directory".format(p=dir)
33 path = os.path.normpath(os.path.join(dir, subdir, resource_name))
34 assert os.path.isfile(path), "{p} is not a file.".format(p=path)
37 def getPathForImage(name):
38 return getPathForResource(resourceBasePath, 'images', name)
40 def getPathForMesh(name):
41 return getPathForResource(resourceBasePath, 'meshes', name)
43 def getPathForFirmware(name):
44 return getPathForResource(resourceBasePath, 'firmware', name)
46 def setupLocalization():
48 if sys.platform.startswith('darwin'):
49 languages = NSLocale.preferredLanguages()
51 languages = [wx.Locale(wx.LANGUAGE_DEFAULT).GetCanonicalName()]
52 except Exception as e:
55 locale_path = os.path.normpath(os.path.join(resourceBasePath, 'locale'))
56 translation = gettext.translation('Cura', locale_path, languages, fallback=True)
57 translation.install(unicode=True)