Commit e97375e4d51d2d8a8fbdbd5221d3c2f8f2b748a5
1 parent
5bba6f75fa
Exists in
master
strip file extension
Showing
1 changed file
with
7 additions
and
4 deletions
Show diff stats
localization.go
... | ... | @@ -5,6 +5,7 @@ import ( |
5 | 5 | "errors" |
6 | 6 | "fmt" |
7 | 7 | "io/ioutil" |
8 | + "path" | |
8 | 9 | "strings" |
9 | 10 | "sync" |
10 | 11 | ) |
... | ... | @@ -36,11 +37,11 @@ func (d *Dictionary) AddTranslations(directory string) error { |
36 | 37 | return err |
37 | 38 | } |
38 | 39 | |
39 | - fmt.Println(fName, path) | |
40 | + loc := stripFileExtension(fName) | |
40 | 41 | |
41 | - break | |
42 | + fmt.Println(fName, path, loc) | |
42 | 43 | |
43 | - loc := stripFileExtension(fName) | |
44 | + break | |
44 | 45 | |
45 | 46 | var data interface{} |
46 | 47 | err = json.Unmarshal(file, &data) |
... | ... | @@ -108,5 +109,7 @@ func (d *Dictionary) parseAcceptedLanguageHeader(acceptedLanguages string) (lang |
108 | 109 | } |
109 | 110 | |
110 | 111 | func stripFileExtension(full string) (stripped string) { |
111 | - return | |
112 | + extension := path.Ext(full) | |
113 | + stripped = strings.TrimSuffix(full, extension) | |
114 | + return stripped | |
112 | 115 | } | ... | ... |