Skip to content

Commit

Permalink
prevent nil exception on empty localization text
Browse files Browse the repository at this point in the history
  • Loading branch information
MJacred committed Jan 3, 2020
1 parent 26334ab commit 99b6afc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions v2/goi18n/merge_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,16 @@ 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 {
return nil, fmt.Errorf("missing translation for message id \"%s\"", m.ID)
}
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 \"%s\"", template.ID)
}
template.Hash = hash(template)
sourceMessageTemplates[template.ID] = template
Expand Down

0 comments on commit 99b6afc

Please sign in to comment.