Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Commit

Permalink
Use dot instead of underscore for localized views
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislas-m committed Nov 27, 2017
1 parent 74338bc commit 0f0171b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions render/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func (s templateRenderer) exec(name string, data Data) (template.HTML, error) {
}

// Try to use localized version
templateName := name
if languages, ok := data["languages"].([]string); ok {
ll := len(languages)
if ll > 0 {
Expand All @@ -75,17 +76,17 @@ func (s templateRenderer) exec(name string, data Data) (template.HTML, error) {
if l == defaultLanguage {
break
}
candidateName = rawName + "_" + strings.ToLower(l) + ext
candidateName = rawName + "." + strings.ToLower(l) + ext
if s.TemplatesBox.Has(candidateName) {
// Replace name with the existing suffixed version
name = candidateName
templateName = candidateName
break
}
}
}
}

source, err := s.TemplatesBox.MustBytes(name)
source, err := s.TemplatesBox.MustBytes(templateName)
if err != nil {
return "", err
}
Expand Down

0 comments on commit 0f0171b

Please sign in to comment.