summaryrefslogtreecommitdiffstats
path: root/output/layout_base.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-11-17 12:27:50 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-11-17 13:08:18 +0100
commit0a81a6b4bae3de53aa9c179b855c671a2d30eec7 (patch)
treeaaeea4e453bbf5b5f61cf0b10fa5d21415c90f00 /output/layout_base.go
parent60dfb9a6e076200ab3ca3fd30e34bb3c14e0a893 (diff)
output: Fall back to unstranslated base template
Fixes #3893
Diffstat (limited to 'output/layout_base.go')
-rw-r--r--output/layout_base.go18
1 files changed, 12 insertions, 6 deletions
diff --git a/output/layout_base.go b/output/layout_base.go
index 79baf9b5f..49ae1d64e 100644
--- a/output/layout_base.go
+++ b/output/layout_base.go
@@ -174,12 +174,18 @@ func CreateTemplateNames(d TemplateLookupDescriptor) (TemplateNames, error) {
// Also note that the <current-path> may be both the project's layout folder and the theme's.
pairsToCheck := createPairsToCheck(baseTemplatedDir, baseFilename, currBaseFilename)
- if strings.Contains(currBaseFilename, ".terms.") {
- // We need to get from baseof.terms.html to baseof.html etc.
- // See #3856
- currBaseFilename = strings.Replace(currBaseFilename, ".terms", "", 1)
- baseFilename = strings.Replace(baseFilename, ".terms", "", 1)
- pairsToCheck = append(pairsToCheck, createPairsToCheck(baseTemplatedDir, baseFilename, currBaseFilename)...)
+ // We may have language code and/or "terms" in the template name. We want the most specific,
+ // but need to fall back to the baseof.html or baseof.ace if needed.
+ // E.g. list-baseof.en.html and list-baseof.terms.en.html
+ // See #3893, #3856.
+ baseBaseFilename, currBaseBaseFilename := helpers.Filename(baseFilename), helpers.Filename(currBaseFilename)
+ p1, p2 := strings.Split(baseBaseFilename, "."), strings.Split(currBaseBaseFilename, ".")
+ if len(p1) > 0 && len(p1) == len(p2) {
+ for i := len(p1); i > 0; i-- {
+ v1, v2 := strings.Join(p1[:i], ".")+"."+ext, strings.Join(p2[:i], ".")+"."+ext
+ pairsToCheck = append(pairsToCheck, createPairsToCheck(baseTemplatedDir, v1, v2)...)
+
+ }
}
Loop: