Skip to content

Commit e3326f8

Browse files
committed
finishing last of comments
1 parent 0a5aadf commit e3326f8

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

hack/update/golang_version/update_golang_version.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ var (
7575
`GO_VERSION: '.*`: `GO_VERSION: '{{.StableVersion}}'`,
7676
},
7777
},
78-
".github/worflows/pr_verified.yaml": {
78+
".github/workflows/pr_verified.yaml": {
7979
Replace: map[string]string{
8080
`GO_VERSION: '.*`: `GO_VERSION: '{{.StableVersion}}'`,
8181
},

pkg/minikube/translate/translate_test.go

+27-8
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ func TestTranslationFilesValid(t *testing.T) {
108108
if err != nil {
109109
t.Fatalf("failed to get translation files: %v", err)
110110
}
111-
re := regexp.MustCompile(`{{\..+?}}`)
112111
for _, filename := range languageFiles {
113112
lang := filepath.Base(filename)
114113
t.Run(lang, func(t *testing.T) {
@@ -136,19 +135,15 @@ func TestTranslationFilesValid(t *testing.T) {
136135
}
137136

138137
// get all variables (ex. {{.name}})
139-
keyVariables := re.FindAllString(k, -1)
140-
valueVariables := re.FindAllString(v, -1)
138+
keyVariables := distinctVariables(k)
139+
valueVariables := distinctVariables(v)
141140

142141
// check if number of original string and translated variables match
143142
if len(keyVariables) != len(valueVariables) {
144-
t.Errorf("line %q has mismatching number of variables; original string variables: %s; translated variables: %s", k, keyVariables, valueVariables)
143+
t.Errorf("line %q: %q has mismatching number of variables\noriginal string variables: %s; translated variables: %s", k, v, keyVariables, valueVariables)
145144
continue
146145
}
147146

148-
// sort so comparing variables is easier
149-
sort.Strings(keyVariables)
150-
sort.Strings(valueVariables)
151-
152147
// for each variable in the original string
153148
for i, keyVar := range keyVariables {
154149
// check if translated string has same variable
@@ -161,3 +156,27 @@ func TestTranslationFilesValid(t *testing.T) {
161156
})
162157
}
163158
}
159+
160+
func distinctVariables(line string) []string {
161+
re := regexp.MustCompile(`{{\..+?}}`)
162+
163+
// get all the variables from the string (possiible duplicates)
164+
variables := re.FindAllString(line, -1)
165+
distinctMap := make(map[string]bool)
166+
167+
// add them to a map to get distinct list of variables
168+
for _, variable := range variables {
169+
distinctMap[variable] = true
170+
}
171+
distinct := []string{}
172+
173+
// convert map into slice
174+
for k := range distinctMap {
175+
distinct = append(distinct, k)
176+
}
177+
178+
// sort the slice to make the comparison easier
179+
sort.Strings(distinct)
180+
181+
return distinct
182+
}

translations/ko.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
"Could not process errors from failed deletion": "",
115115
"Could not resolve IP address": "",
116116
"Country code of the image mirror to be used. Leave empty to use the global one. For Chinese mainland users, set it to cn.": "",
117-
"Creating Kubernetes in {{.driver_name}} {{.machine_type}} with (CPUs={{.number_of_cpus}}) ({{.number_of_host_cpus}} available), Memory={{.memory_size}}MB ({{.host_memory_size}}MB available) ...": "{{.driver_name}} {{.machine_type}} (CPUs={{.number_of_cpus}} ({{.number_of_host_cpus}}MB 유효한), Memory={{.memory_size}}MB ({{.host_memory_size}} MB 유효한) ...",
117+
"Creating Kubernetes in {{.driver_name}} {{.machine_type}} with (CPUs={{.number_of_cpus}}) ({{.number_of_host_cpus}} available), Memory={{.memory_size}}MB ({{.host_memory_size}}MB available) ...": "{{.driver_name}} {{.machine_type}} (CPUs={{.number_of_cpus}} ({{.number_of_host_cpus}}MB 유효한), Memory={{.memory_size}}MB ({{.host_memory_size}}MB 유효한) ...",
118118
"Creating mount {{.name}} ...": "",
119119
"Creating {{.driver_name}} VM (CPUs={{.number_of_cpus}}, Memory={{.memory_size}}MB, Disk={{.disk_size}}MB) ...": "{{.driver_name}} VM (CPUs={{.number_of_cpus}}, Memory={{.memory_size}}MB, Disk={{.disk_size}}MB) 를 생성하는 중 ...",
120120
"Creating {{.driver_name}} {{.machine_type}} (CPUs={{.number_of_cpus}}, Memory={{.memory_size}}MB) ...": "",

0 commit comments

Comments
 (0)