hugo icon indicating copy to clipboard operation
hugo copied to clipboard

Add languagePrefix to language config

Open misitebao opened this issue 3 years ago • 8 comments

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.92.0-B3549403+extended windows/amd64 BuildDate=2022-01-12T08:23:18Z VendorInfo=gohugoio

Does this issue reproduce with the latest release?

Yes!

When I set 'languageCode' with uppercase letters in the configuration file, the generated language folder name is still lowercase.

Language config:

disablePathToLower = true
[en]
contentDir = 'content/en'
languageName = 'English'
languageCode = 'en'
weight = 10
title = "My New Hugo Site"

[zh-Hans]
contentDir = 'content/zh-Hans'
languageName = '简体中文'
languageCode = 'zh-Hans'
weight = 20
title = "我的新Hugo站点"

Generated directory: image

misitebao avatar Jan 18 '22 09:01 misitebao

First, I assume that you placed disablePathToLower = true in the root table of your site config, or in one or more of the [languages.xx] tables. As shown, under the [languages] table, the build will throw en error.

Error: Failed to parse multilingual config: Language config is not a map: bool

Second, disablePathToLower has no effect on the public/langcode directory name. It will always be lowercase.

Third, be aware of this proposal: https://github.com/gohugoio/hugo/issues/9171

Finally, be aware of this issue: https://github.com/gohugoio/hugo/issues/9109 If you use zh-Hans instead of zh_hans, localization of dates, currencies, numbers, and percentages will fail.

Related: https://github.com/gohugoio/hugo/issues/7344

jmooring avatar Jan 18 '22 18:01 jmooring

@jmooring I read these questions carefully. I fully understand the original intention of this design, but I think the choice should be left to the user, determined by the user's configuration, not by Hugo's default decision.

misitebao avatar Jan 18 '22 20:01 misitebao

Can anyone tell me this problem will be fixed?

misitebao avatar Jul 26 '22 18:07 misitebao

This is counterintuitive and problematic when trying to migrate an existing website to Hugo without breaking existing URLs on a case-sensitive server.

DominoPivot avatar Aug 22 '23 18:08 DominoPivot