diff options
-rw-r--r-- | helpers/language.go | 11 | ||||
-rw-r--r-- | hugolib/hugo_sites_test.go | 41 | ||||
-rw-r--r-- | hugolib/multilingual.go | 2 |
3 files changed, 35 insertions, 19 deletions
diff --git a/helpers/language.go b/helpers/language.go index a64809f9f..c822dedd0 100644 --- a/helpers/language.go +++ b/helpers/language.go @@ -24,11 +24,12 @@ import ( ) type Language struct { - Lang string - Title string - Weight int - params map[string]interface{} - paramsInit sync.Once + Lang string + LanguageName string + Title string + Weight int + params map[string]interface{} + paramsInit sync.Once } func (l *Language) String() string { diff --git a/hugolib/hugo_sites_test.go b/hugolib/hugo_sites_test.go index 41535fdf8..3b5bf1cfc 100644 --- a/hugolib/hugo_sites_test.go +++ b/hugolib/hugo_sites_test.go @@ -271,9 +271,10 @@ func doTestMultiSitesBuild(t *testing.T, configContent, configSuffix string) { require.Len(t, homeEn.Translations(), 3) require.Equal(t, "fr", homeEn.Translations()[0].Lang()) require.Equal(t, "nn", homeEn.Translations()[1].Lang()) - require.Equal(t, "Nynorsk", homeEn.Translations()[1].Title) + require.Equal(t, "På nynorsk", homeEn.Translations()[1].Title) require.Equal(t, "nb", homeEn.Translations()[2].Lang()) - require.Equal(t, "Bokmål", homeEn.Translations()[2].Title) + require.Equal(t, "På bokmål", homeEn.Translations()[2].Title, configSuffix) + require.Equal(t, "Bokmål", homeEn.Translations()[2].Language().LanguageName, configSuffix) sectFr := frSite.getNode("sect-sect-0") require.NotNil(t, sectFr) @@ -626,7 +627,8 @@ tag = "tags" [Languages] [Languages.en] weight = 10 -title = "English" +title = "In English" +languageName = "English" [Languages.en.blackfriday] angledQuotes = false [[Languages.en.menu.main]] @@ -636,13 +638,15 @@ weight = 0 [Languages.fr] weight = 20 -title = "Français" +title = "Le Français" +languageName = "Français" [Languages.fr.Taxonomies] plaque = "plaques" [Languages.nn] weight = 30 -title = "Nynorsk" +title = "På nynorsk" +languageName = "Nynorsk" [Languages.nn.Taxonomies] lag = "lag" [[Languages.nn.menu.main]] @@ -652,7 +656,8 @@ weight = 1 [Languages.nb] weight = 40 -title = "Bokmål" +title = "På bokmål" +languageName = "Bokmål" [Languages.nb.Taxonomies] lag = "lag" ` @@ -679,7 +684,8 @@ Taxonomies: Languages: en: weight: 10 - title: "English" + title: "In English" + languageName: "English" blackfriday: angledQuotes: false menu: @@ -689,12 +695,14 @@ Languages: weight: 0 fr: weight: 20 - title: "Français" + title: "Le Français" + languageName: "Français" Taxonomies: plaque: "plaques" nn: weight: 30 - title: "Nynorsk" + title: "På nynorsk" + languageName: "Nynorsk" Taxonomies: lag: "lag" menu: @@ -704,7 +712,8 @@ Languages: weight: 1 nb: weight: 40 - title: "Bokmål" + title: "På bokmål" + languageName: "Bokmål" Taxonomies: lag: "lag" @@ -731,7 +740,8 @@ var multiSiteJSONConfig = ` "Languages": { "en": { "weight": 10, - "title": "English", + "title": "In English", + "languageName": "English", "blackfriday": { "angledQuotes": false }, @@ -747,14 +757,16 @@ var multiSiteJSONConfig = ` }, "fr": { "weight": 20, - "title": "Français", + "title": "Le Français", + "languageName": "Français", "Taxonomies": { "plaque": "plaques" } }, "nn": { "weight": 30, - "title": "Nynorsk", + "title": "På nynorsk", + "languageName": "Nynorsk", "Taxonomies": { "lag": "lag" }, @@ -770,7 +782,8 @@ var multiSiteJSONConfig = ` }, "nb": { "weight": 40, - "title": "Bokmål", + "title": "På bokmål", + "languageName": "Bokmål", "Taxonomies": { "lag": "lag" } diff --git a/hugolib/multilingual.go b/hugolib/multilingual.go index 493a8e8a3..2b0214e10 100644 --- a/hugolib/multilingual.go +++ b/hugolib/multilingual.go @@ -96,6 +96,8 @@ func toSortedLanguages(l map[string]interface{}) (helpers.Languages, error) { switch loki { case "title": language.Title = cast.ToString(v) + case "languagename": + language.LanguageName = cast.ToString(v) case "weight": language.Weight = cast.ToInt(v) } |