MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / main

Function main

tools/generate_i18n.go:29–74  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27)
28
29func 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}

Callers

nothing calls this directly

Calls 7

ReadFileFunction · 0.92
CloneGlobalFunction · 0.92
CleanupMethod · 0.80
WriteFileMethod · 0.80
MergeMethod · 0.45
UpdatedMethod · 0.45
PrintfMethod · 0.45

Tested by

no test coverage detected