mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
parent
e5f9602459
commit
00a238e32c
2 changed files with 16 additions and 10 deletions
|
@ -204,7 +204,7 @@ Data C: {{ $data.c.value }}
|
||||||
Data D: {{ $data.d.value }}
|
Data D: {{ $data.d.value }}
|
||||||
All Data: {{ $data }}
|
All Data: {{ $data }}
|
||||||
|
|
||||||
i18n hello: {{ i18n "hello" . }}
|
i18n hello1: {{ i18n "hello1" . }}
|
||||||
i18n theme: {{ i18n "theme" . }}
|
i18n theme: {{ i18n "theme" . }}
|
||||||
i18n theme2: {{ i18n "theme2" . }}
|
i18n theme2: {{ i18n "theme2" . }}
|
||||||
`)
|
`)
|
||||||
|
@ -238,9 +238,13 @@ other = %q
|
||||||
b.WithSourceFile("themes/d/data/d.toml", `value="Hugo Rodks!"`)
|
b.WithSourceFile("themes/d/data/d.toml", `value="Hugo Rodks!"`)
|
||||||
|
|
||||||
// i18n files
|
// i18n files
|
||||||
b.WithSourceFile("i18n/en.toml", i18nContent("hello", "Project"))
|
b.WithSourceFile("i18n/en.toml", i18nContent("hello1", "Project"))
|
||||||
b.WithSourceFile("themes/c/en.toml", i18nContent("hello", "Theme C"))
|
b.WithSourceFile("themes/c/i18n/en.toml", `
|
||||||
b.WithSourceFile("themes/c/i18n/en.toml", i18nContent("theme", "Theme C"))
|
[hello1]
|
||||||
|
other="Theme C Hello"
|
||||||
|
[theme]
|
||||||
|
other="Theme C"
|
||||||
|
`)
|
||||||
b.WithSourceFile("themes/d/i18n/en.toml", i18nContent("theme", "Theme D"))
|
b.WithSourceFile("themes/d/i18n/en.toml", i18nContent("theme", "Theme D"))
|
||||||
b.WithSourceFile("themes/d/i18n/en.toml", i18nContent("theme2", "Theme2 D"))
|
b.WithSourceFile("themes/d/i18n/en.toml", i18nContent("theme2", "Theme2 D"))
|
||||||
|
|
||||||
|
@ -261,7 +265,7 @@ other = %q
|
||||||
|
|
||||||
// i18n
|
// i18n
|
||||||
b.AssertFileContent("public/index.html",
|
b.AssertFileContent("public/index.html",
|
||||||
"i18n hello: Project",
|
"i18n hello1: Project",
|
||||||
"i18n theme: Theme C",
|
"i18n theme: Theme C",
|
||||||
"i18n theme2: Theme2 D",
|
"i18n theme2: Theme2 D",
|
||||||
)
|
)
|
||||||
|
|
|
@ -50,7 +50,11 @@ func (tp *TranslationProvider) Update(d *deps.Deps) error {
|
||||||
}
|
}
|
||||||
var newLangs []string
|
var newLangs []string
|
||||||
|
|
||||||
for _, dir := range d.BaseFs.I18n.Dirs {
|
// The source dirs are ordered so the most important comes first. Since this is a
|
||||||
|
// last key win situation, we have to reverse the iteration order.
|
||||||
|
dirs := d.BaseFs.I18n.Dirs
|
||||||
|
for i := len(dirs) - 1; i >= 0; i-- {
|
||||||
|
dir := dirs[i]
|
||||||
src := spec.NewFilesystemFromFileMetaInfo(dir)
|
src := spec.NewFilesystemFromFileMetaInfo(dir)
|
||||||
|
|
||||||
files, err := src.Files()
|
files, err := src.Files()
|
||||||
|
@ -71,10 +75,8 @@ func (tp *TranslationProvider) Update(d *deps.Deps) error {
|
||||||
language.RegisterPluralSpec(newLangs, en)
|
language.RegisterPluralSpec(newLangs, en)
|
||||||
}
|
}
|
||||||
|
|
||||||
// The source files are ordered so the most important comes first. Since this is a
|
for _, file := range files {
|
||||||
// last key win situation, we have to reverse the iteration order.
|
if err := addTranslationFile(i18nBundle, file); err != nil {
|
||||||
for i := len(files) - 1; i >= 0; i-- {
|
|
||||||
if err := addTranslationFile(i18nBundle, files[i]); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue