diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/file.go | 16 | ||||
-rw-r--r-- | source/filesystem.go | 3 | ||||
-rw-r--r-- | source/filesystem_test.go | 2 |
3 files changed, 13 insertions, 8 deletions
diff --git a/source/file.go b/source/file.go index 9012b91c4..4bee882a6 100644 --- a/source/file.go +++ b/source/file.go @@ -108,10 +108,11 @@ func (f *File) Path() string { } // NewFileWithContents creates a new File pointer with the given relative path and -// content. +// content. The language defaults to "en". func NewFileWithContents(relpath string, content io.Reader) *File { file := NewFile(relpath) file.Contents = content + file.lang = "en" return file } @@ -124,15 +125,16 @@ func NewFile(relpath string) *File { f.dir, f.logicalName = filepath.Split(f.relpath) f.ext = strings.TrimPrefix(filepath.Ext(f.LogicalName()), ".") f.baseName = helpers.Filename(f.LogicalName()) - if viper.GetBool("Multilingual") { - f.lang = strings.TrimPrefix(filepath.Ext(f.baseName), ".") + + f.lang = strings.TrimPrefix(filepath.Ext(f.baseName), ".") + if f.lang == "" { + f.lang = viper.GetString("DefaultContentLanguage") if f.lang == "" { - f.lang = viper.GetString("DefaultContentLanguage") + // TODO(bep) ml + f.lang = "en" } - f.translationBaseName = helpers.Filename(f.baseName) - } else { - f.translationBaseName = f.baseName } + f.translationBaseName = helpers.Filename(f.baseName) f.section = helpers.GuessSection(f.Dir()) f.uniqueID = helpers.Md5String(f.LogicalName()) diff --git a/source/filesystem.go b/source/filesystem.go index 7bdcd702f..82bcad6e6 100644 --- a/source/filesystem.go +++ b/source/filesystem.go @@ -105,6 +105,9 @@ func (f *Filesystem) captureFiles() { if err != nil { jww.ERROR.Println(err) + if err == helpers.WalkRootTooShortError { + panic("The root path is too short. If this is a test, make sure to init the content paths.") + } } } diff --git a/source/filesystem_test.go b/source/filesystem_test.go index d2101991b..a1e111d2f 100644 --- a/source/filesystem_test.go +++ b/source/filesystem_test.go @@ -22,7 +22,7 @@ import ( ) func TestEmptySourceFilesystem(t *testing.T) { - src := new(Filesystem) + src := &Filesystem{Base: "Empty"} if len(src.Files()) != 0 { t.Errorf("new filesystem should contain 0 files.") } |