Repository: getnikola/nikola

Issue:
Improve experience of multilingual feed autodiscovery
In my multilingual site I had the problem that my RSS reader (Liferea) uses the first RSS feed link when pointed to an HTML page. No choice between the different languages is presented like with the Firefox extension Awesome RSS.

A simple solution might be to make RSS_LINK translatable, but a principle that might improve the feed autodiscovery is to make the RSS feed of the page language the first link in the head tag. The assumption might be that somebody copying a URL for the current page into their feed reader might want the RSS feed corresponding to that language.


Discussion:
RSS_LINK should really go away. It was meant for using a 3rd-party RSS service like feedburner, which is not a thing that exists anymore.

If you don't set RSS_LINK then it should behave the way you expect.
Thank you for the response. Then I guess something else is wrong. I have two languages enabled, 'en' (DEFAULT_LANG), and 'af'. The RSS links are always in the order [af,en] in all HTML files regardless of the language of the page.
Ok, that sounds like something that needs fixing then!

On Fri, Mar 8, 2019 at 1:41 PM friedelwolff <notifications@github.com>
wrote:

> Thank you for the response. Then I guess something else is wrong. I have
> two languages enabled, 'en' (DEFAULT_LANG), and 'af'. The RSS links are
> always in the order [af,en] in all HTML files regardless of the language of
> the page.
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <https://github.com/getnikola/nikola/issues/3248#issuecomment-470993688>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AAAGK-AhqpVp887SbGKMAAnXJWYtrwRmks5vUpKsgaJpZM4bk0jI>
> .
>

Sadly the easy way to change this in the templates would be backwards-incompatible and would break 3rd party themes.

I am looking to see if there is a not-so-easy way :-(

Resolving patch:
diff --git a/nikola/nikola.py b/nikola/nikola.py
--- a/nikola/nikola.py
+++ b/nikola/nikola.py
@@ -1361,6 +1361,10 @@ def render_template(self, template_name, output_name, context, url_type=None, is
             local_context[k] = local_context[k](local_context['lang'])
         local_context['is_rtl'] = local_context['lang'] in LEGAL_VALUES['RTL_LANGUAGES']
         local_context['url_type'] = self.config['URL_TYPE'] if url_type is None else url_type
+        local_context["translations_feedorder"] = sorted(
+            local_context["translations"],
+            key=lambda x: (int(x != local_context['lang']), x)
+        )
         # string, arguments
         local_context["formatmsg"] = lambda s, *a: s % a
         for h in local_context['template_hooks'].values():
diff --git a/nikola/plugins/task/taxonomies.py b/nikola/plugins/task/taxonomies.py
--- a/nikola/plugins/task/taxonomies.py
+++ b/nikola/plugins/task/taxonomies.py
@@ -51,11 +51,12 @@ def _generate_classification_overview_kw_context(self, taxonomy, lang):
         context = copy(context)
         context["kind"] = "{}_index".format(taxonomy.classification_name)
         sorted_links = []
-        sorted_links_all = []
         for other_lang in sorted(self.site.config['TRANSLATIONS'].keys()):
-            sorted_links_all.append((other_lang, None, None))
             if other_lang != lang:
                 sorted_links.append((other_lang, None, None))
+        # Put the current language in front, so that it appears first in links
+        # (Issue #3248)
+        sorted_links_all = [(lang, None, None)] + sorted_links
         context['has_other_languages'] = True
         context['other_languages'] = sorted_links
         context['all_languages'] = sorted_links_all


Test patch: