You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, project.translations is returning all the translations from main_project. I realized that we don't always want this. This is only useful when browsing the source language of the documentation. However, when reading any of its translations project.translationsshould not show the current translation (the one the user is reading) and should show the source language as translation as well.
Example
If the project has English (source language), Spanish and Japanese translations, projects.translations should contain:
Spanish and Japanese, when hitting the English translation
English and Japanese, when hitting the Spanish translation
diff --git a/readthedocs/proxito/views/hosting.py b/readthedocs/proxito/views/hosting.py
index 4b598e21b..780e09091 100644
--- a/readthedocs/proxito/views/hosting.py+++ b/readthedocs/proxito/views/hosting.py@@ -342,7 +342,12 @@ class AddonsResponse:
)
main_project = project.main_language_project or project
- project_translations = main_project.translations.all().order_by("language")+ # Exclude the current project since we don't want to return itself as a translation+ project_translations = main_project.translations.all().exclude(slug=project.slug).order_by("language")++ # Include main project as translation if the current project is one of the translations+ if project != main_project:+ project_translations |= Project.objects.filter(slug=main_project.slug)
data = {
"api_version": "1",
Currently,
project.translations
is returning all the translations frommain_project
. I realized that we don't always want this. This is only useful when browsing the source language of the documentation. However, when reading any of its translationsproject.translations
should not show the current translation (the one the user is reading) and should show the source language as translation as well.Example
If the project has English (source language), Spanish and Japanese translations,
projects.translations
should contain:How to reproduce it
es
is duplicatedThe text was updated successfully, but these errors were encountered: