Added more translation formatting

pull/4797/head
Medya Gh 2019-07-17 16:54:29 -07:00
parent f57f6d724c
commit 4e4eccad30
6 changed files with 15 additions and 13 deletions

View File

@ -58,7 +58,7 @@ func runDelete(cmd *cobra.Command, args []string) {
cc, err := pkg_config.Load()
if err != nil && !os.IsNotExist(err) {
console.ErrLn("Error loading profile config: %v", err)
console.ErrT(console.Sad, "Error loading profile config: {{.error}}", console.Arg{"name": profile})
}
// In the case of "none", we want to uninstall Kubernetes as there is no VM to delete
@ -81,12 +81,12 @@ func runDelete(cmd *cobra.Command, args []string) {
if err := os.RemoveAll(constants.GetProfilePath(viper.GetString(pkg_config.MachineProfile))); err != nil {
if os.IsNotExist(err) {
console.OutStyle(console.Meh, "%q profile does not exist", profile)
console.OutT(console.Meh, `"{{.profile_name}}" profile does not exist`, console.Arg{"profile_name": profile})
os.Exit(0)
}
exit.WithError("Failed to remove profile", err)
}
console.OutStyle(console.Crushed, "The %q cluster has been deleted.", profile)
console.OutT(console.Crushed, `The "{{.cluster_name}}" cluster has been deleted.`, console.Arg{"cluster_name": profile})
machineName := pkg_config.GetMachineName()
if err := pkgutil.DeleteKubeConfigContext(constants.KubeconfigPath, machineName); err != nil {
@ -95,12 +95,12 @@ func runDelete(cmd *cobra.Command, args []string) {
}
func uninstallKubernetes(api libmachine.API, kc pkg_config.KubernetesConfig, bsName string) {
console.OutStyle(console.Resetting, "Uninstalling Kubernetes %s using %s ...", kc.KubernetesVersion, bsName)
console.OutT(console.Resetting, "Uninstalling Kubernetes {{.kubernetes_version}} using {{.bootstrapper_name}} ...", console.Arg{"kubernetes_version": kc.KubernetesVersion, "bootstrapper_name": bsName})
clusterBootstrapper, err := getClusterBootstrapper(api, bsName)
if err != nil {
console.ErrLn("Unable to get bootstrapper: %v", err)
console.ErrT(console.Empty, "Unable to get bootstrapper: {{.error}}", console.Arg{"error": err})
} else if err = clusterBootstrapper.DeleteCluster(kc); err != nil {
console.ErrLn("Failed to delete cluster: %v", err)
console.ErrT(console.Empty, "Failed to delete cluster: {{.error}}", console.Arg{"error": err})
}
}

View File

@ -42,7 +42,7 @@ var ipCmd = &cobra.Command{
if err != nil {
switch err := errors.Cause(err).(type) {
case mcnerror.ErrHostDoesNotExist:
exit.WithCode(exit.NoInput, "%q host does not exist, unable to show an IP", config.GetMachineName())
exit.WithCodeT(exit.NoInput, `"{{.profile_name}}" host does not exist, unable to show an IP`, console.Arg{"profile_name": config.GetMachineName()})
default:
exit.WithError("Error getting host", err)
}

View File

@ -57,7 +57,7 @@ func runStop(cmd *cobra.Command, args []string) {
err = cluster.StopHost(api)
switch err := errors.Cause(err).(type) {
case mcnerror.ErrHostDoesNotExist:
console.OutStyle(console.Meh, "%q VM does not exist, nothing to stop", profile)
console.OutT(console.Meh, `"{{.profile_name}}" VM does not exist, nothing to stop`, console.Arg{"profile_name": profile})
nonexistent = true
return nil
default:
@ -68,11 +68,11 @@ func runStop(cmd *cobra.Command, args []string) {
exit.WithError("Unable to stop VM", err)
}
if !nonexistent {
console.OutStyle(console.Stopped, "%q stopped.", profile)
console.OutT(console.Stopped, `"{{.profile_name}}" stopped.`, console.Arg{"profile_name": profile})
}
if err := cmdUtil.KillMountProcess(); err != nil {
console.OutStyle(console.WarningType, "Unable to kill mount process: %s", err)
console.OutT(console.WarningType, "Unable to kill mount process: {{.error}}", console.Arg{"error": err})
}
machineName := pkg_config.GetMachineName()

View File

@ -78,6 +78,7 @@ var styles = map[StyleEnum]style{
Issues: {Prefix: "⁉️ "},
Issue: {Prefix: " ▪ ", LowPrefix: lowIndent}, // Indented bullet
Check: {Prefix: "✔️ "},
Empty: {Prefix: ""},
// Specialized purpose styles
ISODownload: {Prefix: "💿 "},

View File

@ -79,4 +79,5 @@ const (
Unmount
MountOptions
Fileserver
Empty
)

View File

@ -284,7 +284,7 @@ func WaitAndMaybeOpenService(api libmachine.API, namespace string, service strin
}
if len(urls) == 0 {
console.OutStyle(console.Sad, "service %s/%s has no node port", namespace, service)
console.OutT(console.Sad, "service {{.namespace_name}}/{{.service_name}} has no node port", console.Arg{"namespace_name": namespace, "service_name": service})
return nil
}
@ -294,9 +294,9 @@ func WaitAndMaybeOpenService(api libmachine.API, namespace string, service strin
if urlMode || !isHTTPSchemedURL {
console.OutLn(urlString)
} else {
console.OutStyle(console.Celebrate, "Opening kubernetes service %s/%s in default browser...", namespace, service)
console.OutT(console.Celebrate, "Opening kubernetes service {{.namespace_name}}/{{.service_name}} in default browser...", console.Arg{"namespace_name": namespace, "service_name": service})
if err := browser.OpenURL(urlString); err != nil {
console.Err("browser failed to open url: %v", err)
console.ErrT(console.Empty, "browser failed to open url: {{.error}}", console.Arg{"error": err})
}
}
}