finishing last of comments
parent
0a5aadf502
commit
e3326f88df
|
@ -75,7 +75,7 @@ var (
|
|||
`GO_VERSION: '.*`: `GO_VERSION: '{{.StableVersion}}'`,
|
||||
},
|
||||
},
|
||||
".github/worflows/pr_verified.yaml": {
|
||||
".github/workflows/pr_verified.yaml": {
|
||||
Replace: map[string]string{
|
||||
`GO_VERSION: '.*`: `GO_VERSION: '{{.StableVersion}}'`,
|
||||
},
|
||||
|
|
|
@ -108,7 +108,6 @@ func TestTranslationFilesValid(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("failed to get translation files: %v", err)
|
||||
}
|
||||
re := regexp.MustCompile(`{{\..+?}}`)
|
||||
for _, filename := range languageFiles {
|
||||
lang := filepath.Base(filename)
|
||||
t.Run(lang, func(t *testing.T) {
|
||||
|
@ -136,19 +135,15 @@ func TestTranslationFilesValid(t *testing.T) {
|
|||
}
|
||||
|
||||
// get all variables (ex. {{.name}})
|
||||
keyVariables := re.FindAllString(k, -1)
|
||||
valueVariables := re.FindAllString(v, -1)
|
||||
keyVariables := distinctVariables(k)
|
||||
valueVariables := distinctVariables(v)
|
||||
|
||||
// check if number of original string and translated variables match
|
||||
if len(keyVariables) != len(valueVariables) {
|
||||
t.Errorf("line %q has mismatching number of variables; original string variables: %s; translated variables: %s", k, keyVariables, valueVariables)
|
||||
t.Errorf("line %q: %q has mismatching number of variables\noriginal string variables: %s; translated variables: %s", k, v, keyVariables, valueVariables)
|
||||
continue
|
||||
}
|
||||
|
||||
// sort so comparing variables is easier
|
||||
sort.Strings(keyVariables)
|
||||
sort.Strings(valueVariables)
|
||||
|
||||
// for each variable in the original string
|
||||
for i, keyVar := range keyVariables {
|
||||
// check if translated string has same variable
|
||||
|
@ -161,3 +156,27 @@ func TestTranslationFilesValid(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func distinctVariables(line string) []string {
|
||||
re := regexp.MustCompile(`{{\..+?}}`)
|
||||
|
||||
// get all the variables from the string (possiible duplicates)
|
||||
variables := re.FindAllString(line, -1)
|
||||
distinctMap := make(map[string]bool)
|
||||
|
||||
// add them to a map to get distinct list of variables
|
||||
for _, variable := range variables {
|
||||
distinctMap[variable] = true
|
||||
}
|
||||
distinct := []string{}
|
||||
|
||||
// convert map into slice
|
||||
for k := range distinctMap {
|
||||
distinct = append(distinct, k)
|
||||
}
|
||||
|
||||
// sort the slice to make the comparison easier
|
||||
sort.Strings(distinct)
|
||||
|
||||
return distinct
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@
|
|||
"Could not process errors from failed deletion": "",
|
||||
"Could not resolve IP address": "",
|
||||
"Country code of the image mirror to be used. Leave empty to use the global one. For Chinese mainland users, set it to cn.": "",
|
||||
"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 유효한) ...",
|
||||
"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 유효한) ...",
|
||||
"Creating mount {{.name}} ...": "",
|
||||
"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) 를 생성하는 중 ...",
|
||||
"Creating {{.driver_name}} {{.machine_type}} (CPUs={{.number_of_cpus}}, Memory={{.memory_size}}MB) ...": "",
|
||||
|
|
Loading…
Reference in New Issue