Repository: WeblateOrg/weblate

Issue:
Limit the number of "Other components" displayed
**Is your feature request related to a problem? Please describe.**
In projects with many components, listing them all on a component page is excessive, making the page many times longer than it needs to be. For example: https://translations.documentfoundation.org/projects/libo_ui-master/cuimessages/fi/

**Describe the solution you'd like**
Is it necessary to display "Other components" on the component page at all? If it is, the list should at least be collapsed by default, if the number of components exceeds (say) 10.

**Describe alternatives you've considered**
Including simply a link to the page that shows the components.

**Additional context**


<bountysource-plugin>

---
Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/92127724-limit-the-number-of-other-components-displayed?utm_campaign=plugin&utm_content=tracker%2F253393&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F253393&utm_medium=issues&utm_source=github).
</bountysource-plugin>


Discussion:
It was introduced to give bigger visibility to related translations, see https://github.com/WeblateOrg/weblate/issues/559, but it certainly makes sense to limit the listing to a few of them (preferring not translated ones) and include link to full list (https://translations.documentfoundation.org/languages/fi/libo_ui-master/ in your case).
@tjhietala I think the current limit elsewhere is how many items you can reasonably fit on a UHD-display on its side. That is 60 or so. On https://translations.documentfoundation.org/languages/fi/libo_ui-master/ is something like 90.
I would expect to find all components in "components". What are "other components" in that regard?
@comradekingu Just click on link in first post to see that ;-)
Hii @nijel  i am new to open source  so can i work on this. ?
@krishnmohan19 You are welcome.

The related code is here (note the logic for adding ghost translations):

https://github.com/WeblateOrg/weblate/blob/138d10ad14e8ef3962670fa3faea7ac2dbe1bc2c/weblate/trans/views/basic.py#L299-L316

And template is here:

https://github.com/WeblateOrg/weblate/blob/138d10ad14e8ef3962670fa3faea7ac2dbe1bc2c/weblate/templates/translation.html#L184-L191

Resolving patch:
diff --git a/weblate/trans/views/basic.py b/weblate/trans/views/basic.py
--- a/weblate/trans/views/basic.py
+++ b/weblate/trans/views/basic.py
@@ -306,7 +306,7 @@ def show_translation(request, project, component, lang):
     )
 
     # Include ghost translations for other components, this
-    # adds quick way to create transaltions in other components
+    # adds quick way to create translations in other components
     existing = {translation.component.slug for translation in other_translations}
     existing.add(obj.component.slug)
     for test_component in obj.component.project.component_set.filter_access(
@@ -315,6 +315,11 @@ def show_translation(request, project, component, lang):
         if test_component.can_add_new_language(user):
             other_translations.append(GhostTranslation(test_component, obj.language))
 
+    # Limit the number of other components displayed to 10, preferring untranslated ones
+    other_translations = sorted(
+        other_translations, key=lambda t: t.stats.translated_percent
+    )[:10]
+
     return render(
         request,
         "translation.html",


Test patch: