Commit a750b26ad594ec589629b45d345a947a4ec8f397

Authored by tatiana
1 parent e0382a10

ENH: Translation source-code adjustments

invesalius/constants.py
... ... @@ -43,7 +43,7 @@ TEXT_POS_RIGHT_DOWN = (1-X, 1-Y) # SetVerticalJustificationToBottom &
43 43 # SetJustificationToRight
44 44 #------------------------------------------------------------------
45 45 TEXT_POS_HCENTRE_DOWN = (0.5, 1-Y) # SetJustificationToCentered
46   - # SetVerticalJustificationToBottom
  46 + # ChildrticalJustificationToBottom
47 47 #------------------------------------------------------------------
48 48 TEXT_POS_HCENTRE_UP = (0.5, Y) # SetJustificationToCentered
49 49 #------------------------------------------------------------------
... ... @@ -102,13 +102,13 @@ MODE_ODONTOLOGY = 3
102 102  
103 103 #Color Table from Slice
104 104 #NumberOfColors, SaturationRange, HueRange, ValueRange
105   -SLICE_COLOR_TABLE = {"Default ":(None,(0,0),(0,0),(0,1)),
106   - "Hue":(None,(1,1),(0,1),(1,1)),
107   - "Saturation":(None,(0,1),(0.6,0.6),(1,1)),
108   - "Desert":(256, (1,1), (0, 0.1), (1,1)),
109   - "Rainbow":(256,(1,1),(0,0.8),(1,1)),
110   - "Ocen":(256,(1,1),(0.667, 0.5),(1,1)),
111   - "Inverse Gray":(256, (0, 0), (0, 0), (1,0)),
  105 +SLICE_COLOR_TABLE = {_("Default "):(None,(0,0),(0,0),(0,1)),
  106 + _("Hue"):(None,(1,1),(0,1),(1,1)),
  107 + _("Saturation"):(None,(0,1),(0.6,0.6),(1,1)),
  108 + _("Desert"):(256, (1,1), (0, 0.1), (1,1)),
  109 + _("Rainbow"):(256,(1,1),(0,0.8),(1,1)),
  110 + _("Ocen"):(256,(1,1),(0.667, 0.5),(1,1)),
  111 + _("Inverse Gray"):(256, (0, 0), (0, 0), (1,0)),
112 112 }
113 113  
114 114 # Volume view angle
... ... @@ -149,14 +149,14 @@ VOLUME_POSITION = {AXIAL: [AXIAL_VOLUME_CAM_VIEW_UP, AXIAL_VOLUME_CAM_POSITION],
149 149  
150 150 # Mask threshold options
151 151 proj = Project()
152   -THRESHOLD_RANGE = proj.threshold_modes["Bone"]
  152 +THRESHOLD_RANGE = proj.threshold_modes[_("Bone")]
153 153 THRESHOLD_PRESETS_INDEX = 0 #Bone
154 154 THRESHOLD_HUE_RANGE = (0, 0.6667)
155 155 THRESHOLD_INVALUE = 5000
156 156 THRESHOLD_OUTVALUE = 0
157 157  
158 158 # Mask properties
159   -MASK_NAME_PATTERN = "Mask %d"
  159 +MASK_NAME_PATTERN = _("Mask %d")
160 160 MASK_OPACITY = 0.40
161 161 #MASK_OPACITY = 0.35
162 162 MASK_COLOUR = [(0.33, 1, 0.33),
... ... @@ -185,7 +185,7 @@ BRUSH_DRAW = 0
185 185 BRUSH_ERASE = 1
186 186 BRUSH_THRESH = 2
187 187 DEFAULT_BRUSH_OP = BRUSH_THRESH
188   -BRUSH_OP_NAME = ["Draw", "Erase", "Threshold"]
  188 +BRUSH_OP_NAME = [_("Draw"), _("Erase"), _("Threshold")]
189 189  
190 190 BRUSH_COLOUR = (0,0,1.0)
191 191 BRUSH_SIZE = 30
... ... @@ -196,36 +196,36 @@ BRUSH_SIZE = 30
196 196 # 2: smooth_relaxation_factor
197 197 # 3: decimate_reduction
198 198 SURFACE_QUALITY = {
199   - "Low": (3, 2, 0.3000, 0.4),
200   - "Medium": (2, 2, 0.3000, 0.4),
201   - "High": (0, 1, 0.3000, 0.1),
202   - "Optimal": (0, 2, 0.3000, 0.4),
203   - "Custom": (None, None, None, None)}
204   -DEFAULT_SURFACE_QUALITY = "Optimal"
  199 + _("Low"): (3, 2, 0.3000, 0.4),
  200 + _("Medium"): (2, 2, 0.3000, 0.4),
  201 + _("High"): (0, 1, 0.3000, 0.1),
  202 + _("Optimal *"): (0, 2, 0.3000, 0.4),
  203 + _("Custom"): (None, None, None, None)}
  204 +DEFAULT_SURFACE_QUALITY = _("Optimal *")
205 205  
206 206 # Surface properties
207 207 SURFACE_TRANSPARENCY = 0.0
208   -SURFACE_NAME_PATTERN = "Surface %d"
  208 +SURFACE_NAME_PATTERN = _("Surface %d")
209 209  
210 210 # Imagedata - window and level presets
211   -WINDOW_LEVEL = {"Abdomen":(350,50),
212   - "Bone":(2000, 300),
213   - "Brain Posterior Fossa":(120,40),
214   - "Brain":(80,40),
215   - "Default":(None, None), #Control class set window and level from DICOM
216   - "Emphysema":(500,-850),
217   - "Ischemia - Hard Non Contrast":(15,32),
218   - "Ischemia - Soft Non Contrast":(80,20),
219   - "Larynx":(180, 80),
220   - "Liver":(2000, -500),
221   - "Lung - Soft":(1600,-600),
222   - "Lung - Hard":(1000,-600),
223   - "Mediastinum":(350,25),
224   - "Manual":(None, None), #Case the user change window and level
225   - "Pelvis": (450,50),
226   - "Sinus":(4000, 400),
227   - "Vasculature - Hard":(240,80),
228   - "Vasculature - Soft":(650,160)}
  211 +WINDOW_LEVEL = {_("Abdomen"):(350,50),
  212 + _("Bone"):(2000, 300),
  213 + _("Brain Posterior Fossa"):(120,40),
  214 + _("Brain"):(80,40),
  215 + _("Default"):(None, None), #Control class set window and level from DICOM
  216 + _("Emphysema"):(500,-850),
  217 + _("Ischemia - Hard Non Contrast"):(15,32),
  218 + _("Ischemia - Soft Non Contrast"):(80,20),
  219 + _("Larynx"):(180, 80),
  220 + _("Liver"):(2000, -500),
  221 + _("Lung - Soft"):(1600,-600),
  222 + _("Lung - Hard"):(1000,-600),
  223 + _("Mediastinum"):(350,25),
  224 + _("Manual"):(None, None), #Case the user change window and level
  225 + _("Pelvis"): (450,50),
  226 + _("Sinus"):(4000, 400),
  227 + _("Vasculature - Hard"):(240,80),
  228 + _("Vasculature - Soft"):(650,160)}
229 229  
230 230 if (sys.platform == 'win32') and (platform.architecture()[0] == '32bit'):
231 231 REDUCE_IMAGEDATA_QUALITY = 1
... ... @@ -235,15 +235,14 @@ else:
235 235 REDUCE_IMAGEDATA_QUALITY = 0
236 236  
237 237 ICON_DIR = os.path.abspath(os.path.join('..', 'icons'))
238   -LANGUAGE_DIR = os.path.abspath(os.path.join('..','locale'))
239   -
240   -ID_TO_BMP = {VOL_FRONT: ["Front", os.path.join(ICON_DIR, "view_front.png")],
241   - VOL_BACK: ["Back", os.path.join(ICON_DIR, "view_back.png")],
242   - VOL_TOP: ["Top", os.path.join(ICON_DIR, "view_top.png")],
243   - VOL_BOTTOM: ["Bottom", os.path.join(ICON_DIR, "view_bottom.png")],
244   - VOL_RIGHT: ["Right", os.path.join(ICON_DIR, "view_right.png")],
245   - VOL_LEFT: ["Left", os.path.join(ICON_DIR, "view_left.png")],
246   - VOL_ISO:["Isometric", os.path.join(ICON_DIR,"view_isometric.png")]
  238 +
  239 +ID_TO_BMP = {VOL_FRONT: [_("Front"), os.path.join(ICON_DIR, "view_front.png")],
  240 + VOL_BACK: [_("Back"), os.path.join(ICON_DIR, "view_back.png")],
  241 + VOL_TOP: [_("Top"), os.path.join(ICON_DIR, "view_top.png")],
  242 + VOL_BOTTOM: [_("Bottom"), os.path.join(ICON_DIR, "view_bottom.png")],
  243 + VOL_RIGHT: [_("Right"), os.path.join(ICON_DIR, "view_right.png")],
  244 + VOL_LEFT: [_("Left"), os.path.join(ICON_DIR, "view_left.png")],
  245 + VOL_ISO:[_("Isometric"), os.path.join(ICON_DIR,"view_isometric.png")]
247 246 }
248 247  
249 248 # if 1, use vtkVolumeRaycastMapper, if 0, use vtkFixedPointVolumeRayCastMapper
... ... @@ -252,7 +251,38 @@ TYPE_RAYCASTING_MAPPER = 1
252 251 folder=RAYCASTING_PRESETS_DIRECTORY= os.path.abspath(os.path.join("..",
253 252 "presets",
254 253 "raycasting"))
255   -RAYCASTING_TYPES = [filename.split(".")[0] for filename in
  254 +_("Airways")
  255 +_("Airways II")
  256 +_("Black & White")
  257 +_("Bone + Skin")
  258 +_("Bone + Skin II")
  259 +_("Dark Bone")
  260 +_("Glossy")
  261 +_("Glossy II")
  262 +_("Gold Bone")
  263 +_("High Contrast")
  264 +_("Low Contrast")
  265 +_("Soft on White")
  266 +_("Mid Contrast")
  267 +_("No Shading")
  268 +_("Pencil")
  269 +_("Red on White")
  270 +_("Skin On Blue")
  271 +_("Skin On Blue II")
  272 +_("Soft on White")
  273 +_("Soft + Skin")
  274 +_("Soft + Skin II")
  275 +_("Soft + Skin III")
  276 +_("Soft On Blue")
  277 +_("Soft")
  278 +_("Standard")
  279 +_("Vascular")
  280 +_("Vascular II")
  281 +_("Vascular III")
  282 +_("Vascular IV")
  283 +_("Yellow Bone")
  284 +
  285 +RAYCASTING_TYPES = [_(filename.split(".")[0]) for filename in
256 286 os.listdir(folder) if
257 287 os.path.isfile(os.path.join(folder,filename))]
258 288  
... ... @@ -260,13 +290,13 @@ folder = os.path.join(os.path.expanduser('~'), '.invesalius', 'presets')
260 290 if not os.path.isdir(folder):
261 291 os.makedirs(folder)
262 292 USER_RAYCASTING_PRESETS_DIRECTORY = folder
263   -RAYCASTING_TYPES += [filename.split(".")[0] for filename in
  293 +RAYCASTING_TYPES += [_(filename.split(".")[0]) for filename in
264 294 os.listdir(folder) if
265 295 os.path.isfile(os.path.join(folder,filename))]
266   -RAYCASTING_TYPES.append(' Off')
  296 +RAYCASTING_TYPES.append(_(' Off'))
267 297 RAYCASTING_TYPES.sort()
268   -RAYCASTING_OFF_LABEL = ' Off'
269   -RAYCASTING_TOOLS = ["Cut plane"]
  298 +RAYCASTING_OFF_LABEL = _(' Off')
  299 +RAYCASTING_TOOLS = [_("Cut plane")]
270 300  
271 301 # If 0 dont't blur, 1 blur
272 302 RAYCASTING_WWWL_BLUR = 0
... ...
invesalius/gui/data_notebook.py
... ... @@ -398,7 +398,7 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin):
398 398 else:
399 399 print "unchecked, ", index
400 400  
401   - def InsertNewItem(self, index=0, type_="Mask 1", value="(1000, 4500)",
  401 + def InsertNewItem(self, index=0, type_="", value="(1000, 4500)",
402 402 colour=None):
403 403 self.InsertStringItem(index, "")
404 404 self.SetStringItem(index, 1, type_, imageId = self.img_colour)
... ...
invesalius/gui/dicom_preview_panel.py
... ... @@ -320,8 +320,8 @@ class SingleImagePreview(wx.Panel):
320 320 self.dicom_list = []
321 321 self.nimages = 1
322 322 self.current_index = 0
323   - self.window_width = const.WINDOW_LEVEL["Bone"][0]
324   - self.window_level = const.WINDOW_LEVEL["Bone"][1]
  323 + self.window_width = const.WINDOW_LEVEL[_("Bone")][0]
  324 + self.window_level = const.WINDOW_LEVEL[_("Bone")][1]
325 325  
326 326 def __init_vtk(self):
327 327 actor = vtk.vtkImageActor()
... ...
invesalius/gui/language_dialog.py
... ... @@ -22,8 +22,8 @@ import wx
22 22 import wx.combo
23 23  
24 24 import i18n
25   -import constants as const
26 25  
  26 +ICON_DIR = os.path.abspath(os.path.join('..', 'icons'))
27 27  
28 28 class LanguageDialog(wx.Dialog):
29 29 """Class define the language to be used in the InVesalius,
... ... @@ -46,9 +46,9 @@ class LanguageDialog(wx.Dialog):
46 46  
47 47 self.bitmapCmb = bitmapCmb = wx.combo.BitmapComboBox(self, style=wx.CB_READONLY)
48 48  
49   - bmp_brazilian_flag = wx.Bitmap(os.path.join(const.ICON_DIR, "pt_BR.bmp"), wx.BITMAP_TYPE_BMP)
50   - bmp_english_flag = wx.Bitmap(os.path.join(const.ICON_DIR, "en_GB.bmp"), wx.BITMAP_TYPE_BMP)
51   - bmp_spanish_flag = wx.Bitmap(os.path.join(const.ICON_DIR, "es.bmp"), wx.BITMAP_TYPE_BMP)
  49 + bmp_brazilian_flag = wx.Bitmap(os.path.join(ICON_DIR, "pt_BR.bmp"), wx.BITMAP_TYPE_BMP)
  50 + bmp_english_flag = wx.Bitmap(os.path.join(ICON_DIR, "en_GB.bmp"), wx.BITMAP_TYPE_BMP)
  51 + bmp_spanish_flag = wx.Bitmap(os.path.join(ICON_DIR, "es.bmp"), wx.BITMAP_TYPE_BMP)
52 52  
53 53 bitmapCmb.Append(self.locales[0], bmp_english_flag,"en_GB")
54 54 bitmapCmb.Append(self.locales[1], bmp_brazilian_flag,"pt_BR")
... ...
invesalius/gui/task_surface.py
... ... @@ -29,7 +29,7 @@ import gui.widgets.foldpanelbar as fpb
29 29 #INTERPOLATION_MODE_LIST = ["Cubic", "Linear", "NearestNeighbor"]
30 30 QUALITY_LIST = [_("Low"), _("Medium"), _("High"), _("Optimal *"), _("Custom")]
31 31 SURFACE_LIST = []
32   -MASK_LIST = ["Mask 1"]
  32 +MASK_LIST = []
33 33 MIN_TRANSPARENCY = 0
34 34 MAX_TRANSPARENCY = 100
35 35  
... ...
invesalius/i18n.py
... ... @@ -26,7 +26,7 @@ import gettext
26 26 import os
27 27 import sys
28 28  
29   -import constants as const
  29 +LANGUAGE_DIR = os.path.abspath(os.path.join('..','locale'))
30 30  
31 31 def GetLocales():
32 32 """Return a dictionary which defines supported languages"""
... ... @@ -45,7 +45,7 @@ def GetLocaleOS():
45 45  
46 46 def InstallLanguage(language):
47 47  
48   - lang = gettext.translation('invesalius', const.LANGUAGE_DIR,\
  48 + lang = gettext.translation('invesalius', LANGUAGE_DIR,\
49 49 languages=[language], codeset='utf8')
50 50 # Using unicode
51 51 lang.install(unicode=1)
... ...
invesalius/presets.py
... ... @@ -27,39 +27,39 @@ class Presets():
27 27  
28 28 def __init__(self):
29 29 self.thresh_ct = TwoWaysDictionary({
30   - "Bone":(226,3071),
31   - "Soft Tissue":(-700,225),
32   - "Enamel (Adult)":(1553,2850),
33   - "Enamel (Child)":(2042,3071),
34   - "Compact Bone (Adult)":(662,1988),
35   - "Compact Bone (Child)":(586,2198),
36   - "Spongial Bone (Adult)":(148,661),
37   - "Spongial Bone (Child)":(156,585),
38   - "Muscle Tissue (Adult)":(-5,135),
39   - "Muscle Tissue (Child)":(-25,139),
40   - "Fat Tissue (Adult)":(-205,-51),
41   - "Fat Tissue (Adult)":(-212,-72),
42   - "Skin Tissue (Adult)":(-718,-177),
43   - "Skin Tissue (Child)":(-766,-202),
44   - "Custom":('', '')
  30 + _("Bone"):(226,3071),
  31 + _("Soft Tissue"):(-700,225),
  32 + _("Enamel (Adult)"):(1553,2850),
  33 + _("Enamel (Child)"):(2042,3071),
  34 + _("Compact Bone (Adult)"):(662,1988),
  35 + _("Compact Bone (Child)"):(586,2198),
  36 + _("Spongial Bone (Adult)"):(148,661),
  37 + _("Spongial Bone (Child)"):(156,585),
  38 + _("Muscle Tissue (Adult)"):(-5,135),
  39 + _("Muscle Tissue (Child)"):(-25,139),
  40 + _("Fat Tissue (Adult)"):(-205,-51),
  41 + _("Fat Tissue (Child)"):(-212,-72),
  42 + _("Skin Tissue (Adult)"):(-718,-177),
  43 + _("Skin Tissue (Child)"):(-766,-202),
  44 + _("Custom"):('', '')
45 45 })
46 46  
47 47 self.thresh_mri = TwoWaysDictionary({
48   - "Bone":(1250,4095),
49   - "Soft Tissue":(324,1249),
50   - "Enamel (Adult)":(2577,3874),
51   - "Enamel (Child)":(3066,4095),
52   - "Compact Bone (Adult)":(1686,3012),
53   - "Compact Bone (Child)":(1610,3222),
54   - "Spongial Bone (Adult)":(1172,1685),
55   - "Spongial Bone (Child)":(1180,1609),
56   - "Muscle Tissue (Adult)":(1019,1159),
57   - "Muscle Tissue (Child)":(999,1163),
58   - "Fat Tissue (Adult)":(819,973),
59   - "Fat Tissue (Adult)":(812,952),
60   - "Skin Tissue (Adult)":(306,847),
61   - "Skin Tissue (Child)":(258,822),
62   - "Custom":('', '')
  48 + _("Bone"):(1250,4095),
  49 + _("Soft Tissue"):(324,1249),
  50 + _("Enamel (Adult)"):(2577,3874),
  51 + _("Enamel (Child)"):(3066,4095),
  52 + _("Compact Bone (Adult)"):(1686,3012),
  53 + _("Compact Bone (Child)"):(1610,3222),
  54 + _("Spongial Bone (Adult)"):(1172,1685),
  55 + _("Spongial Bone (Child)"):(1180,1609),
  56 + _("Muscle Tissue (Adult)"):(1019,1159),
  57 + _("Muscle Tissue (Child)"):(999,1163),
  58 + _("Fat Tissue (Adult)"):(819,973),
  59 + _("Fat Tissue (Child)"):(812,952),
  60 + _("Skin Tissue (Adult)"):(306,847),
  61 + _("Skin Tissue (Child)"):(258,822),
  62 + _("Custom"):('', '')
63 63 })
64 64 self.__bind_events()
65 65  
... ... @@ -116,5 +116,5 @@ class Presets():
116 116  
117 117 def Test(self):
118 118 print "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
119   - print self.thresh_ct.get_value("Bone")
  119 + print self.thresh_ct.get_value(_("Bone"))
120 120 print "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
... ...
invesalius/session.py
... ... @@ -4,7 +4,6 @@ from threading import Thread
4 4 import time
5 5 import wx.lib.pubsub as ps
6 6  
7   -import constants as const
8 7 from utils import Singleton
9 8  
10 9 import wx.lib.pubsub as ps
... ... @@ -24,6 +23,7 @@ class Session(object):
24 23 ps.Publisher().subscribe(self.StopRecording, "Stop Config Recording")
25 24  
26 25 def CreateItens(self):
  26 + import constants as const
27 27 self.project_path = ()
28 28 self.debug = False
29 29  
... ... @@ -55,6 +55,7 @@ class Session(object):
55 55  
56 56  
57 57 def CloseProject(self):
  58 + import constants as const
58 59 print "-- CloseProject"
59 60 self.project_path = ()
60 61 self.project_status = const.PROJ_CLOSE
... ... @@ -62,6 +63,7 @@ class Session(object):
62 63 self.temp_item = False
63 64  
64 65 def SaveProject(self, path=()):
  66 + import constants as const
65 67 print "-- SaveProject"
66 68 self.project_status = const.PROJ_OPEN
67 69 if path:
... ... @@ -71,10 +73,12 @@ class Session(object):
71 73 self.temp_item = False
72 74  
73 75 def ChangeProject(self):
  76 + import constants as const
74 77 print "-- ChangeProject"
75 78 self.project_status = const.PROJ_CHANGE
76 79  
77 80 def CreateProject(self, filename):
  81 + import constants as const
78 82 print "-- CreateProject"
79 83 # Set session info
80 84 self.project_path = (self.tempdir, filename)
... ... @@ -83,6 +87,7 @@ class Session(object):
83 87 return self.tempdir
84 88  
85 89 def OpenProject(self, filepath):
  90 + import constants as const
86 91 print "-- OpenProject"
87 92 # Add item to recent projects list
88 93 item = (path, file) = os.path.split(filepath)
... ... @@ -123,6 +128,7 @@ class Session(object):
123 128  
124 129  
125 130 def __add_to_list(self, item):
  131 + import constants as const
126 132 # Last projects list
127 133 l = self.recent_projects
128 134  
... ... @@ -226,4 +232,4 @@ class WriteSession(Thread):
226 232  
227 233  
228 234  
229   -
230 235 \ No newline at end of file
  236 +
... ...