diff options
-rw-r--r-- | hugolib/hugo_modules_test.go | 11 | ||||
-rw-r--r-- | langs/i18n/translationProvider.go | 5 |
2 files changed, 12 insertions, 4 deletions
diff --git a/hugolib/hugo_modules_test.go b/hugolib/hugo_modules_test.go index ff3d01c04..464230437 100644 --- a/hugolib/hugo_modules_test.go +++ b/hugolib/hugo_modules_test.go @@ -701,10 +701,13 @@ Data: {{ .Site.Data }} createSymlinks := func(baseDir, id string) { for _, dir := range files.ComponentFolders { - c.Assert(os.Chdir(filepath.Join(baseDir, dir)), qt.IsNil) - c.Assert(os.Symlink("real", fmt.Sprintf("realsym%s", id)), qt.IsNil) - c.Assert(os.Chdir(filepath.Join(baseDir, dir, "real")), qt.IsNil) - c.Assert(os.Symlink("data.toml", fmt.Sprintf(filepath.FromSlash("datasym%s.toml"), id)), qt.IsNil) + // Issue #9119: private use language tags cannot exceed 8 characters. + if dir != "i18n" { + c.Assert(os.Chdir(filepath.Join(baseDir, dir)), qt.IsNil) + c.Assert(os.Symlink("real", fmt.Sprintf("realsym%s", id)), qt.IsNil) + c.Assert(os.Chdir(filepath.Join(baseDir, dir, "real")), qt.IsNil) + c.Assert(os.Symlink("data.toml", fmt.Sprintf(filepath.FromSlash("datasym%s.toml"), id)), qt.IsNil) + } } } diff --git a/langs/i18n/translationProvider.go b/langs/i18n/translationProvider.go index 9e82b18d9..44bd52f0c 100644 --- a/langs/i18n/translationProvider.go +++ b/langs/i18n/translationProvider.go @@ -93,6 +93,11 @@ func addTranslationFile(bundle *i18n.Bundle, r source.File) error { lang := paths.Filename(name) tag := language.Make(lang) if tag == language.Und { + try := artificialLangTagPrefix + lang + _, err = language.Parse(try) + if err != nil { + return _errors.Errorf("%q %s.", try, err) + } name = artificialLangTagPrefix + name } |