Closed LuHugo closed 1 year ago
'zh-CN': {
label: '简体中文',
lang: 'zh-CN'
}
Change the above code to the code below.
'zh': {
label: '简体中文',
lang: 'zh-CN'
}
And change the folder name to zh
.
For more information, see https://starlight.astro.build/guides/i18n/#configure-i18n.
'zh-CN': { label: '简体中文', lang: 'zh-CN' }
Change the above code to the code below.
'zh': { label: '简体中文', lang: 'zh-CN' }
And change the folder name to
zh
.For more information, see https://starlight.astro.build/guides/i18n/#configure-i18n.
@jsparkdev
I know this is completely feasible, but how to define en-US
, en-CA
, en-UK
at the same time and what the routing should be. Is it possible to do routing like: http://localhost:4321/en-US/docs/
and http://localhost:4321/en-UK/docs/
.
If you use keys like enus
or enuk
, the meaning is not very clear.
Some examples I have seen :
https://developer.mozilla.org/en-US/docs/Web
https://docusaurus.io/zh-CN/docs
https://www.microsoft.com/en-sg/
https://www.rust-lang.org/zh-CN/learn
https://www.rust-lang.org/zh-TW/learn
Ideally, this feature should support keys such as en-US
, en-UK
, etc. I don't know if this is intentionally designed like this or if it is a bug. It would be really great if such a configuration could be achieved.
If I am not missing anything, this is the expected behavior.
Each route segments in a content collection are slugified using github-slugger
. This change was introduced in https://github.com/withastro/astro/pull/5666 and the maintainCase
option, which defaults to false
, is not used meaning that every character is lowercased.
To handle en-US
, en-CA
, en-UK
you can use the same pattern used in the Starlight documentation for pt-BR
:
pt-br
locale key with a pt-BR
labelpt-br
folderThe generated URLs will be https://starlight.astro.build/pt-br/guides/i18n/
for example with pt-br
avoiding the enus
or enuk
like you mentioned.
If I am not missing anything, this is the expected behavior.
Each route segments in a content collection are slugified using
github-slugger
. This change was introduced in withastro/astro#5666 and themaintainCase
option, which defaults tofalse
, is not used meaning that every character is lowercased.To handle
en-US
,en-CA
,en-UK
you can use the same pattern used in the Starlight documentation forpt-BR
:
pt-br
locale key with apt-BR
labelpt-br
folderThe generated URLs will be
https://starlight.astro.build/pt-br/guides/i18n/
for example withpt-br
avoiding theenus
orenuk
like you mentioned.
@HiDeoo Thank you, this is very good. I noticed the maintainCase
parameter you mentioned. Can it be reconfigured to true by the user? If it can be set to true, can the folder (with a name similar to en-US
, etc.) be generated correctly?
Can it be reconfigured to true by the user?
At the moment, this parameter is not something used or exposed in Astro and this is where this change would need to happen I guess. Altho, I guess a good first step would be to open an issue in the Astro repo to discuss this, not sure if this is something that would be accepted or not, maybe there is a good reason why this is done this way and not configurable I don't know. etc.
Got it, I think it would be a good idea to allow users to keep the original folder naming.
What version of
starlight
are you using?0.10.2
What version of
astro
are you using?3.0.6
What package manager are you using?
yarn
What operating system are you using?
Mac
What browser are you using?
Edge
Describe the Bug
When multiple languages are configured, the built directory ignores uppercase letters and changes them all to lowercase letters, which results in routing to the 404 page.
build logs
In the built folder
dist
, thezh-cn
directory will be generated, and the correct one should be thezh-CN
directory.Link to Minimal Reproducible Example
No response
Participation