Skip to content

Use Django language codes for project languages#12895

Draft
ericholscher wants to merge 3 commits intomainfrom
codex/rtd-language-codes-django
Draft

Use Django language codes for project languages#12895
ericholscher wants to merge 3 commits intomainfrom
codex/rtd-language-codes-django

Conversation

@ericholscher
Copy link
Copy Markdown
Member

Summary

  • switch project language choices to Django's standard LANGUAGES
  • map deprecated RTD language codes to their Django equivalents across URL resolution, redirects, and Sphinx language normalization
  • add deploy-safe migrations to update existing Project and HistoricalProject rows before changing schema choices

Closes #4411.

Details

  • 0159_migrate_language_codes_to_django is a Safe.before_deploy() data migration
  • 0160_alter_historicalproject_language_and_more is a Safe.after_deploy() schema migration
  • old underscore and renamed codes like pt_BR, zh_CN, and bare zh continue to resolve and redirect to canonical Django codes

Testing

  • DJANGO_SETTINGS_MODULE=readthedocs.settings.proxito.test /Users/eric/projects/readthedocs.org/.venv/bin/pytest --reuse-db readthedocs/proxito/tests/test_full.py -k 'old_language_code or renamed_old_language_code or sitemap_xml'
  • DJANGO_SETTINGS_MODULE=readthedocs.settings.test /Users/eric/projects/readthedocs.org/.venv/bin/pytest --reuse-db readthedocs/projects/tests/test_build_tasks.py -k 'sphinx_normalized_language or sphinx_normalized_script_language'
  • DJANGO_SETTINGS_MODULE=readthedocs.settings.test /Users/eric/projects/readthedocs.org/.venv/bin/python manage.py makemigrations projects --check --dry-run

Notes

  • a full repo-wide makemigrations --check --dry-run still reports an unrelated pending migration in readthedocs-ext/donate; this branch does not modify that app.

Apply ruff format to constants.py and migration 0160. Fix the
test_translation_zh_deprecated_code_serving test to use "zh-hans" (the
valid Django code) as the project language and verify that accessing the
deprecated "/zh/" URL correctly redirects to "/zh-hans/".
@read-the-docs-community
Copy link
Copy Markdown

Documentation build overview

📚 dev | 🛠️ Build #32142673 | 📁 Comparing f1eaf26 against latest (63e5ba2)

  🔍 Preview build  

Show files changed (1 files in total): 📝 1 modified | ➕ 0 added | ➖ 0 deleted
File Status
aws-temporary-credentials.html 📝 modified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rtd ist not following language code update for Chinese

1 participant