Merge pull request #7696 from afbjorklund/translations-statistics

Show statistics when extracting the translations
pull/7702/head
Medya Ghazizadeh 2020-04-15 14:45:57 -07:00 committed by GitHub
commit 17f6cdedb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 1 deletions

View File

@ -454,7 +454,7 @@ func writeStringsToFiles(e *state, output string) error {
if !strings.HasSuffix(path, ".json") {
return nil
}
fmt.Printf("Writing to %s\n", filepath.Base(path))
fmt.Printf("Writing to %s", filepath.Base(path))
currentTranslations := make(map[string]interface{})
f, err := ioutil.ReadFile(path)
if err != nil {
@ -482,6 +482,16 @@ func writeStringsToFiles(e *state, output string) error {
}
}
t := 0 // translated
u := 0 // untranslated
for k, _ := range e.translations{
if currentTranslations[k] != "" {
t++
} else {
u++
}
}
c, err := json.MarshalIndent(currentTranslations, "", "\t")
if err != nil {
return errors.Wrap(err, "marshalling translations")
@ -490,6 +500,8 @@ func writeStringsToFiles(e *state, output string) error {
if err != nil {
return errors.Wrap(err, "writing translation file")
}
fmt.Printf(" (%d translated, %d untranslated)\n", t, u)
return nil
})