Skip to content

Commit

Permalink
localization fix (legacy files)
Browse files Browse the repository at this point in the history
  • Loading branch information
zelenin committed Feb 5, 2023
1 parent ad8e52e commit 8fd61a6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/datasheet-converter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func normalizeCellValue(column datasheet.Column, str string) any {
return nil
}

// ugly rounding fix
//ugly rounding fix
pow := math.Pow(10, 6)
return math.Round(val*pow) / pow
}
Expand Down
13 changes: 12 additions & 1 deletion localization/localization.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,24 @@ func New(root string) (*internal.Store[string], error) {
return nil, err
}

var isLegacyFile bool

var resources Resources
err = xml.NewDecoder(xmlFile).Decode(&resources)
if err != nil {
return nil, err
if strings.Contains(err.Error(), "expected element type") {
isLegacyFile = true
}
if !isLegacyFile {
return nil, err
}
}
xmlFile.Close()

if isLegacyFile {
continue
}

for _, resource := range resources.Strings {
if resource.Nil {
continue
Expand Down

0 comments on commit 8fd61a6

Please sign in to comment.