Skip to content

Commit

Permalink
prevent nil exception on empty localization text
Browse files Browse the repository at this point in the history
fixes #207
  • Loading branch information
MJacred committed Jan 9, 2020
1 parent 26334ab commit 71f6d8d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions v2/goi18n/merge_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,17 @@ func merge(messageFiles map[string][]byte, sourceLanguageTag language.Tag, outdi
}
templates := map[string]*i18n.MessageTemplate{}
for _, m := range mf.Messages {
templates[m.ID] = i18n.NewMessageTemplate(m)
template := i18n.NewMessageTemplate(m)
if template == nil {
fmt.Fprintf(os.Stderr, "missing translation for message id %q\n", m.ID)
continue
}
templates[m.ID] = template
}
if mf.Tag == sourceLanguageTag {
for _, template := range templates {
if sourceMessageTemplates[template.ID] != nil {
return nil, fmt.Errorf("multiple source translations for id %s", template.ID)
return nil, fmt.Errorf("multiple source translations for id %q", template.ID)
}
template.Hash = hash(template)
sourceMessageTemplates[template.ID] = template
Expand Down

0 comments on commit 71f6d8d

Please sign in to comment.