diff --git a/pkg/text/print.go b/pkg/text/print.go index edbc73d8..6ecfa5df 100644 --- a/pkg/text/print.go +++ b/pkg/text/print.go @@ -6,6 +6,7 @@ import ( "strconv" "strings" "syscall" + "unicode" "github.com/leonelquinteros/gotext" "golang.org/x/sys/unix" @@ -84,13 +85,29 @@ func getColumnCount() int { } func PrintInfoValue(key string, values ...string) { - // 16 (text) + 1 (:) + 1 ( ) const ( - keyLength = 18 + keyLength = 32 delimCount = 2 ) - str := fmt.Sprintf(Bold("%-16s: "), key) + specialWordsCount := 0 + + for _, runeValue := range key { + // CJK handling: the character 'ー' is Katakana + // but if use unicode.Katakana, it will return false + if unicode.IsOneOf([]*unicode.RangeTable{ + unicode.Han, + unicode.Hiragana, + unicode.Katakana, + unicode.Hangul, + }, runeValue) || runeValue == 'ー' { + specialWordsCount++ + } + } + + keyTextCount := specialWordsCount - keyLength + delimCount + str := fmt.Sprintf(Bold("%-*s: "), keyTextCount, key) + if len(values) == 0 || (len(values) == 1 && values[0] == "") { fmt.Fprintf(os.Stdout, "%s%s\n", str, gotext.Get("None")) return