New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Addons: don't return current translation and include source language in projects.translations
field
#11292
Comments
I think something like this could work: 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", |
I tested the previous diff locally and it works fine 👍🏼 . I need to open a PR and write some tests. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: