Commit afe704d3ddd655e9be713bf57e1b979ff2ca1797
1 parent
8c0472fa
Exists in
master
and in
6 other branches
FIX: inv3/UI localization problem (fix #118)
Showing
2 changed files
with
57 additions
and
12 deletions
Show diff stats
invesalius/presets.py
... | ... | @@ -99,22 +99,68 @@ class Presets(): |
99 | 99 | def SavePlist(self, filename): |
100 | 100 | filename = "%s$%s" % (filename, 'presets.plist') |
101 | 101 | preset = {} |
102 | - preset['thresh_mri'] = self.thresh_mri.copy() | |
103 | - preset['thresh_ct'] = self.thresh_ct.copy() | |
102 | + | |
103 | + translate_to_en = {_("Bone"):"Bone", | |
104 | + _("Soft Tissue"):"Soft Tissue", | |
105 | + _("Enamel (Adult)"):"Enamel (Adult)", | |
106 | + _("Enamel (Child)"): "Enamel (Child)", | |
107 | + _("Compact Bone (Adult)"):"Compact Bone (Adult)", | |
108 | + _("Compact Bone (Child)"):"Compact Bone (Child)", | |
109 | + _("Spongial Bone (Adult)"):"Spongial Bone (Adult)", | |
110 | + _("Spongial Bone (Child)"):"Spongial Bone (Child)", | |
111 | + _("Muscle Tissue (Adult)"):"Muscle Tissue (Adult)", | |
112 | + _("Muscle Tissue (Child)"):"Muscle Tissue (Child)", | |
113 | + _("Fat Tissue (Adult)"):"Fat Tissue (Adult)", | |
114 | + _("Fat Tissue (Child)"):"Fat Tissue (Child)", | |
115 | + _("Skin Tissue (Adult)"):"Skin Tissue (Adult)", | |
116 | + _("Skin Tissue (Child)"):"Skin Tissue (Child)", | |
117 | + _("Custom"):"Custom"} | |
118 | + | |
119 | + thresh_mri_new = {} | |
120 | + for name in self.thresh_mri.keys(): | |
121 | + thresh_mri_new[translate_to_en[name]] = self.thresh_mri[name] | |
122 | + | |
123 | + thresh_ct_new = {} | |
124 | + for name in self.thresh_ct.keys(): | |
125 | + thresh_ct_new[translate_to_en[name]] = self.thresh_ct[name] | |
126 | + | |
127 | + preset['thresh_mri'] = thresh_mri_new | |
128 | + preset['thresh_ct'] = thresh_ct_new | |
104 | 129 | plistlib.writePlist(preset, filename) |
105 | 130 | return os.path.split(filename)[1] |
106 | 131 | |
107 | 132 | def OpenPlist(self, filename): |
133 | + | |
134 | + translate_to_x = {"Bone":_("Bone"), | |
135 | + "Soft Tissue":_("Soft Tissue"), | |
136 | + "Enamel (Adult)":_("Enamel (Adult)"), | |
137 | + "Enamel (Child)": _("Enamel (Child)"), | |
138 | + "Compact Bone (Adult)": _("Compact Bone (Adult)"), | |
139 | + "Compact Bone (Child)":_("Compact Bone (Child)"), | |
140 | + "Spongial Bone (Adult)":_("Spongial Bone (Adult)"), | |
141 | + "Spongial Bone (Child)":_("Spongial Bone (Child)"), | |
142 | + "Muscle Tissue (Adult)":_("Muscle Tissue (Adult)"), | |
143 | + "Muscle Tissue (Child)":_("Muscle Tissue (Child)"), | |
144 | + "Fat Tissue (Adult)":_("Fat Tissue (Adult)"), | |
145 | + "Fat Tissue (Child)":_("Fat Tissue (Child)"), | |
146 | + "Skin Tissue (Adult)":_("Skin Tissue (Adult)"), | |
147 | + "Skin Tissue (Child)":_("Skin Tissue (Child)"), | |
148 | + "Custom":_("Custom")} | |
149 | + | |
150 | + | |
108 | 151 | p = plistlib.readPlist(filename) |
109 | - d1 = p['thresh_mri'].copy() | |
110 | - d2 = p['thresh_ct'].copy() | |
111 | - | |
112 | - self.thresh_mri = TwoWaysDictionary(d1) | |
113 | - self.thresh_ct = TwoWaysDictionary(d2) | |
152 | + thresh_mri = p['thresh_mri'].copy() | |
153 | + thresh_ct = p['thresh_ct'].copy() | |
154 | + | |
155 | + thresh_ct_new = {} | |
156 | + for name in thresh_ct.keys(): | |
157 | + thresh_ct_new[translate_to_x[name]] = thresh_ct[name] | |
158 | + | |
159 | + thresh_mri_new = {} | |
160 | + for name in thresh_mri.keys(): | |
161 | + thresh_mri_new[translate_to_x[name]] = thresh_mri[name] | |
114 | 162 | |
163 | + self.thresh_mri = TwoWaysDictionary(thresh_mri_new) | |
164 | + self.thresh_ct = TwoWaysDictionary(thresh_ct_new) | |
115 | 165 | |
116 | 166 | |
117 | - def Test(self): | |
118 | - print "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" | |
119 | - print self.thresh_ct.get_value(_("Bone")) | |
120 | - print "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" | ... | ... |
invesalius/project.py