Skip to content

Commit

Permalink
storage: locale: Translate advance partitions
Browse files Browse the repository at this point in the history
Add translation for advanced partitions as well as new strings
related to the media changes which will be done in confirmation.

Add new tests.

Signed-off-by: Mark D Horn <[email protected]>
  • Loading branch information
mdhorn committed Sep 13, 2019
1 parent db3a17c commit e7b383f
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 15 deletions.
42 changes: 42 additions & 0 deletions locale/en_US/LC_MESSAGES/clr-installer.po
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,22 @@ msgstr "Launch the external partitioning tool to label the partitions to be used
msgid "Could not launch %s. Check log %s"
msgstr "Could not launch %s. Check log %s"

#, c-format
msgid "%s must be %s"
msgstr "%s must be %s"

#, c-format
msgid "Found multiple %s partition labels"
msgstr "Found multiple %s partition labels"

#, c-format
msgid "Encryption of %s is not supported"
msgstr "Encryption of %s is not supported"

#, c-format
msgid "Missing %s partition label"
msgstr "Missing %s partition label"

msgid "CHANGE LANGUAGE"
msgstr "CHANGE LANGUAGE"

Expand Down Expand Up @@ -706,3 +722,29 @@ msgstr "Version URL of mirror not found"

msgid "."
msgstr "."

#, c-format
msgid "Formatting partition as %s."
msgstr "Formatting partition as %s."

msgid "Selected media will be used for installation."
msgstr "Selected media will be used for installation."

#, c-format
msgid "Updating partition table for: %s"
msgstr "Updating partition table for: %s"

msgid "WARNING: partition will be removed."
msgstr "WARNING: partition will be removed."

msgid "Adding new partition."
msgstr "Adding new partition."

msgid "WARNING: Failed to detected partition information."
msgstr "WARNING: Failed to detected partition information."

msgid "Reusing existing partition."
msgstr "Reusing existing partition."

msgid "Encrypted"
msgstr "Encrypted"
42 changes: 42 additions & 0 deletions locale/es_MX/LC_MESSAGES/clr-installer.po
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,22 @@ msgstr "MX: Launch the external partitioning tool to label the partitions to be
msgid "Could not launch %s. Check log %s"
msgstr "MX: Could not launch %s. Check log %s"

#, c-format
msgid "%s must be %s"
msgstr "MX: %s must be %s"

#, c-format
msgid "Found multiple %s partition labels"
msgstr "MX: Found multiple %s partition labels"

#, c-format
msgid "Encryption of %s is not supported"
msgstr "MX: Encryption of %s is not supported"

#, c-format
msgid "Missing %s partition label"
msgstr "MX: Missing %s partition label"

msgid "CHANGE LANGUAGE"
msgstr "CAMBIAR IDIOMA"

Expand Down Expand Up @@ -706,3 +722,29 @@ msgstr "Versión URL del espejo no encontrada"

msgid "."
msgstr "."

#, c-format
msgid "Formatting partition as %s."
msgstr "MX: Formatting partition as %s."

msgid "Selected media will be used for installation."
msgstr "MX: Selected media will be used for installation."

#, c-format
msgid "Updating partition table for: %s"
msgstr "MX: Updating partition table for: %s"

msgid "WARNING: partition will be removed."
msgstr "MX: WARNING: partition will be removed."

msgid "Adding new partition."
msgstr "MX: Adding new partition."

msgid "WARNING: Failed to detected partition information."
msgstr "MX: WARNING: Failed to detected partition information."

msgid "Reusing existing partition."
msgstr "MX: Reusing existing partition."

msgid "Encrypted"
msgstr "MX: Encrypted"
42 changes: 42 additions & 0 deletions locale/zh_CN/LC_MESSAGES/clr-installer.po
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,22 @@ msgstr "CN: Launch the external partitioning tool to label the partitions to be
msgid "Could not launch %s. Check log %s"
msgstr "CN: Could not launch %s. Check log %s"

#, c-format
msgid "%s must be %s"
msgstr "CN: %s must be %s"

#, c-format
msgid "Found multiple %s partition labels"
msgstr "CN: Found multiple %s partition labels"

#, c-format
msgid "Encryption of %s is not supported"
msgstr "CN: Encryption of %s is not supported"

#, c-format
msgid "Missing %s partition label"
msgstr "CN: Missing %s partition label"

msgid "CHANGE LANGUAGE"
msgstr "更改语言"

Expand Down Expand Up @@ -706,3 +722,29 @@ msgstr "未找到镜像的版本 URL"

msgid "."
msgstr "。"

#, c-format
msgid "Formatting partition as %s."
msgstr "CN: Formatting partition as %s."

msgid "Selected media will be used for installation."
msgstr "CN: Selected media will be used for installation."

#, c-format
msgid "Updating partition table for: %s"
msgstr "CN: Updating partition table for: %s"

msgid "WARNING: partition will be removed."
msgstr "CN: WARNING: partition will be removed."

msgid "Adding new partition."
msgstr "CN: Adding new partition."

msgid "WARNING: Failed to detected partition information."
msgstr "CN: WARNING: Failed to detected partition information."

msgid "Reusing existing partition."
msgstr "CN: Reusing existing partition."

msgid "Encrypted"
msgstr "CN: Encrypted"
22 changes: 11 additions & 11 deletions storage/ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -1519,42 +1519,42 @@ func ValidateAdvancedPartitions(medias []*BlockDevice) []string {
switch lowerPart {
case "boot":
if bootFound {
warning := fmt.Sprintf("Found multiple %s partition labels", "CLR_BOOT")
warning := utils.Locale.Get("Found multiple %s partition labels", "CLR_BOOT")
results = append(results, warning)
log.Warning("ValidateAdvancedPartitions: %s %+v", warning, ch)
} else {
bootFound = true
if ch.FsType != "vfat" {
warning := fmt.Sprintf("%s must be %s", "CLR_BOOT", "vfat")
warning := utils.Locale.Get("%s must be %s", "CLR_BOOT", "vfat")
results = append(results, warning)
log.Warning("ValidateAdvancedPartitions: %s %+v", warning, ch)
}
}
case "root":
if rootFound {
warning := fmt.Sprintf("Found multiple %s partition labels", "CLR_ROOT")
warning := utils.Locale.Get("Found multiple %s partition labels", "CLR_ROOT")
results = append(results, warning)
log.Warning("ValidateAdvancedPartitions: %s %+v", warning, ch)
} else {
rootFound = true
if !(ch.FsType == "ext2" || ch.FsType == "ext3" ||
ch.FsType == "ext4" || ch.FsType == "xfs") {
warning := fmt.Sprintf("%s must be %s", "CLR_ROOT", "ext*|xfs")
warning := utils.Locale.Get("%s must be %s", "CLR_ROOT", "ext*|xfs")
results = append(results, warning)
log.Warning("ValidateAdvancedPartitions: %s %+v", warning, ch)
}
}
case "swap":
if swapFound {
warning := fmt.Sprintf("Found multiple %s partition labels", "CLR_SWAP")
warning := utils.Locale.Get("Found multiple %s partition labels", "CLR_SWAP")
results = append(results, warning)
log.Warning("ValidateAdvancedPartitions: %s %+v", warning, ch)
} else {
swapFound = true
}
case "e":
if strings.HasPrefix(strings.ToLower(ch.PartitionLabel), "clr_boot") {
warning := fmt.Sprintf("Encryption of %s is not supported", "CLR_BOOT")
warning := utils.Locale.Get("Encryption of %s is not supported", "CLR_BOOT")
results = append(results, warning)
log.Warning("ValidateAdvancedPartitions: %s %+v", warning, ch)
}
Expand All @@ -1564,19 +1564,19 @@ func ValidateAdvancedPartitions(medias []*BlockDevice) []string {
}

if !bootFound {
warning := fmt.Sprintf("Missing %s partition label", "CLR_BOOT")
warning := utils.Locale.Get("Missing %s partition label", "CLR_BOOT")
results = append(results, warning)
log.Warning("ValidateAdvancedPartitions: %s", warning)
}

if !swapFound {
warning := fmt.Sprintf("Missing %s partition label", "CLR_SWAP")
warning := utils.Locale.Get("Missing %s partition label", "CLR_SWAP")
results = append(results, warning)
log.Warning("ValidateAdvancedPartitions: %s", warning)
}

if !rootFound {
warning := fmt.Sprintf("Missing %s partition label", "CLR_ROOT")
warning := utils.Locale.Get("Missing %s partition label", "CLR_ROOT")
results = append(results, warning)
log.Warning("ValidateAdvancedPartitions: %s", warning)
}
Expand Down Expand Up @@ -1665,7 +1665,7 @@ func getPlannedPartitionChanges(media *BlockDevice) []string {
}

if ch.Type == BlockDeviceTypeCrypt {
part = part + " Encrypted"
part = part + " " + utils.Locale.Get("Encrypted")
}

results = append(results, part)
Expand All @@ -1685,7 +1685,7 @@ func getPlannedPartitionChanges(media *BlockDevice) []string {
}

if ch.Type == BlockDeviceTypeCrypt {
part = part + " Encrypted"
part = part + " " + utils.Locale.Get("Encrypted")
}
results = append(results, part)
}
Expand Down
24 changes: 20 additions & 4 deletions storage/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,17 +560,23 @@ func TestWritePartition(t *testing.T) {
}
}()
bd.Name = path.Base(file)
part1 := &BlockDevice{Name: bd.Name + "p1", FsType: "vfat", Size: 157286400, Type: BlockDeviceTypePart, MountPoint: "/boot"}
part2 := &BlockDevice{Name: bd.Name + "p2", FsType: "swap", Size: 125829120, Type: BlockDeviceTypePart, MountPoint: ""}
part3 := &BlockDevice{Name: bd.Name + "p3", FsType: "ext4", Size: 502267904, Type: BlockDeviceTypePart, MountPoint: "/"}
part4 := &BlockDevice{Name: bd.Name + "p4", FsType: "ext4", Size: 502267904, Type: BlockDeviceTypeCrypt, MountPoint: "/home"}
part1 := &BlockDevice{Name: bd.Name + "p1", FsType: "vfat", Size: 157286400, PartitionLabel: "CLR_BOOT", Type: BlockDeviceTypePart, MountPoint: "/boot"}
part2 := &BlockDevice{Name: bd.Name + "p2", FsType: "swap", Size: 125829120, PartitionLabel: "CLR_SWAP", Type: BlockDeviceTypePart, MountPoint: ""}
part3 := &BlockDevice{Name: bd.Name + "p3", FsType: "ext4", Size: 502267904, PartitionLabel: "CLR_ROOT_F_E", Type: BlockDeviceTypePart, MountPoint: "/"}
part4 := &BlockDevice{Name: bd.Name + "p4", FsType: "ext4", Size: 502267904, PartitionLabel: "CLR_MNT_/home", Type: BlockDeviceTypeCrypt, MountPoint: "/home"}

children = append(children, part1)
children = append(children, part2)
children = append(children, part3)
children = append(children, part4)
bd.Children = children

//write the partition table (dryrun)
results := []string{}
if err = bd.WritePartitionTable(false, true, &results); err != nil {
t.Fatalf("Could not dryrun write partition table (%s): %s", file, err)
}

//write the partition table
if err = bd.WritePartitionTable(false, true, nil); err != nil {
t.Fatalf("Could not write partition table (%s): %s", file, err)
Expand All @@ -591,6 +597,16 @@ func TestWritePartition(t *testing.T) {
}
}
bds := []*BlockDevice{bd}

found := FindAdvancedInstallTargets(bds)
if len(found) > 0 {
t.Fatalf("Should not have found any advanced targets %+v", found)
}

if !AdvancedPartitionsRequireEncryption(bds) {
t.Fatalf("Advanced targets should require encryption")
}

if scanErr := UpdateBlockDevices(bds); scanErr != nil {
t.Fatalf("Could not UpdateBlockDevices: %s", scanErr)
}
Expand Down

0 comments on commit e7b383f

Please sign in to comment.