| 27 | ) |
| 28 | |
| 29 | func main() { |
| 30 | messagesFile := "config/messages.json" |
| 31 | if len(os.Args) == 2 { |
| 32 | messagesFile = os.Args[1] |
| 33 | } |
| 34 | |
| 35 | messages, err := i18n.ReadFile(messagesFile) |
| 36 | if err != nil && !os.IsNotExist(err) { |
| 37 | panic(err) |
| 38 | } |
| 39 | |
| 40 | global := i18n.CloneGlobal() |
| 41 | global.Merge(messages) |
| 42 | |
| 43 | updated := global.Updated() |
| 44 | if len(updated) > 0 { |
| 45 | fmt.Println("Updated the following messages:") |
| 46 | for _, updated := range updated { |
| 47 | fmt.Printf(" - %s\n", updated) |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | deleted := global.Cleanup() |
| 52 | if len(deleted) > 0 { |
| 53 | fmt.Println("Deleted the following messages:") |
| 54 | for _, deleted := range deleted { |
| 55 | fmt.Printf(" - %s\n", deleted) |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | count := make(map[string]int) |
| 60 | for _, msg := range global { |
| 61 | for lang := range msg.Translations { |
| 62 | count[lang] = count[lang] + 1 |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | for lang, count := range count { |
| 67 | fmt.Printf("Language: %s\tTranslations: %5d\tMissing: %5d\n", lang, count, len(global)-count) |
| 68 | } |
| 69 | |
| 70 | err = global.WriteFile(messagesFile) |
| 71 | if err != nil { |
| 72 | panic(err) |
| 73 | } |
| 74 | } |