even more translatable strings in the fs view and some more flexibility wrt string lengths

This commit is contained in:
Michael Hudson-Doyle 2018-04-19 12:46:32 +12:00
parent 47b5acab92
commit febc40cd45
2 changed files with 26 additions and 18 deletions

View File

@ -54,6 +54,15 @@ class DiskPartitionView(BaseView):
def _build_model_inputs(self):
partitioned_disks = []
if self.disk.free > 0:
if len(self.disk.partitions()) > 0:
final_label = _("Add another partition")
else:
final_label = _("Add first partition")
label_width = max(25, len(final_label) + 4)
else:
label_width = 25
def format_volume(label, part):
size = humanize_size(part.size)
if part.fs() is None:
@ -70,27 +79,23 @@ class DiskPartitionView(BaseView):
else:
part_btn = menu_btn(label, on_press=self._click_part, user_arg=part)
return Columns([
(25, part_btn),
(label_width, part_btn),
(9, Text(size, align="right")),
Text(fstype),
Text(mountpoint),
], 2)
if self.disk.fs() is not None:
partitioned_disks.append(format_volume("entire disk", self.disk))
partitioned_disks.append(format_volume(_("entire disk"), self.disk))
else:
for part in self.disk.partitions():
partitioned_disks.append(format_volume("Partition {}".format(part._number), part))
partitioned_disks.append(format_volume(_("Partition {}").format(part._number), part))
if self.disk.free > 0:
free_space = humanize_size(self.disk.free)
if len(self.disk.partitions()) > 0:
label = "Add another partition"
else:
label = "Add first partition"
add_btn = menu_btn(label, on_press=self.add_partition)
add_btn = menu_btn(final_label, on_press=self.add_partition)
partitioned_disks.append(Columns([
(25, add_btn),
(label_width, add_btn),
(9, Text(free_space, align="right")),
Text("free space"),
Text(_("free space")),
], 2))
if self.model.bootable():
for p in self.disk.partitions():
@ -102,8 +107,7 @@ class DiskPartitionView(BaseView):
button_pile([other_btn(label=_("Select as boot disk"), on_press=self.make_boot_disk)]))
if len(self.disk.partitions()) == 0 and \
self.disk.available:
text = ("Format or create swap on entire "
"device (unusual, advanced)")
text = _("Format or create swap on entire device (unusual, advanced)")
partitioned_disks.append(Text(""))
partitioned_disks.append(
menu_btn(label=text, on_press=self.format_entire))
@ -119,7 +123,7 @@ class DiskPartitionView(BaseView):
def show_disk_info_w(self):
""" Runs hdparm against device and displays its output
"""
text = ("Show disk information")
text = _("Show disk information")
return menu_btn(
label=text,
on_press=self.show_disk_info)

View File

@ -137,14 +137,18 @@ class FilesystemView(BaseView):
if len(cols) == 0:
return Pile([Color.info_minor(
Text(_("No disks or partitions mounted.")))])
cols.insert(0, (None, mount_point_text, _("SIZE"), _("TYPE"), _("DEVICE TYPE")))
size_text = _("SIZE")
type_text = _("TYPE")
size_width = max(len(size_text), 9)
type_width = max(len(type_text), self.model.longest_fs_name)
cols.insert(0, (None, mount_point_text, size_text, type_text, _("DEVICE TYPE")))
pl = []
for dummy, a, b, c, d in cols:
if b == "SIZE":
b = Text(b, align='center')
else:
b = Text(b, align='right')
pl.append(Columns([(longest_path, Text(a)), (9, b), (self.model.longest_fs_name, Text(c)), Text(d)], 4))
pl.append(Columns([(longest_path, Text(a)), (size_width, b), (type_width, Text(c)), Text(d)], 4))
return Pile(pl)
def _build_buttons(self):
@ -166,11 +170,11 @@ class FilesystemView(BaseView):
r = []
def col3(col1, col2, col3):
inputs.append(Columns([(40, col1), (10, col2), (10, col3)], 2))
inputs.append(Columns([(42, col1), (10, col2), col3], 2))
def col2(col1, col2):
inputs.append(Columns([(40, col1), col2], 2))
inputs.append(Columns([(42, col1), col2], 2))
def col1(col1):
inputs.append(Columns([(40, col1)], 1))
inputs.append(Columns([(42, col1)], 1))
inputs = []
col3(Text(_("DEVICE")), Text(_("SIZE"), align="center"), Text(_("TYPE")))