-
Notifications
You must be signed in to change notification settings - Fork 2
/
localize.go
62 lines (44 loc) · 1.09 KB
/
localize.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package main
import (
"flag"
"fmt"
. "localize/parser"
. "localize/reader"
. "localize/record"
. "localize/writer"
)
func main() {
csvFile := flag.String("file", "", "csv file name with absolute path")
platform := flag.String("platform", "", "target platform: ios/android/web")
debugFlag := flag.Bool("debug", false, "enable detailed logs for debugging: true/false")
flag.Parse()
if *csvFile == "" {
fmt.Println("Invalid input for file name/path.")
return
}
fmt.Println("Reading from file:", *csvFile)
data := ReadFile(csvFile)
recordList := ParseData(data)
channelMap := make(map[string]chan Record)
for i, locale := range data[0] {
if i == 0 {
continue
}
channelMap[locale] = make(chan Record)
}
for i, locale := range data[0] {
if i == 0 {
continue
}
go WriteFile(*platform, locale, channelMap[locale], *debugFlag)
}
fmt.Println("Writing strings to files... ")
for i, record := range recordList {
channelMap[record.Locale] <- record
if i == len(recordList)-1 {
for k, _ := range channelMap {
CloseFile(*platform, k, *debugFlag)
}
}
}
}