readthedocs / ext-theme

Read the Docs drop in replacement site templates
2 stars 2 forks source link

Project's detail: 500 when loading on `zh` language #358

Closed humitos closed 3 months ago

humitos commented 3 months ago

Opening https://beta.readthedocs.org/projects/paddlescience-docs/ gives 500. It seems to be related to a translation issue. Also, going to https://beta.readthedocs.org/projects/mikrotik-doc-cn/builds/22789572/ fails as well.

humitos commented 3 months ago

Both projects have "Chinese" as language.

humitos commented 3 months ago

It seems that "zh" | language_name_local fails in the templates because zh is not valid.

It fails at https://github.com/readthedocs/ext-theme/blob/d758c66ed0d4cce607e7405a3e2cb8e216f15ff8/readthedocsext/theme/templates/projects/partials/header.html#L32

humitos commented 3 months ago

Removing the | language_name_local filter makes the page to work.

humitos commented 3 months ago

It generates this

Screenshot_2024-05-27_11-32-27

humitos commented 3 months ago

zh as is does not exist in Django, https://github.com/django/django/blob/d3a7ed5bcc45000a6c3dd55d85a4caaa83299f83/django/conf/locale/__init__.py#L599-L628

agjohnson commented 3 months ago

This is a larger issue, zh isn't a valid locale in Sphinx either: https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-language

In both, the supported locales should be zh_CN and zh_TW.

The fix here shouldn't be to remove the language_name_local though, the code is not a user friendly way to present the language of the project. We should avoid this for the invalid zh locale for now, and perhaps this makes more sense as a model method on the project.

But we should modernize our list of supported locales too probably.