Skip to content
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

Language code for pages in header nav.main missing #126

Open
rickelt opened this issue Mar 23, 2023 · 0 comments
Open

Language code for pages in header nav.main missing #126

rickelt opened this issue Mar 23, 2023 · 0 comments

Comments

@rickelt
Copy link

rickelt commented Mar 23, 2023

When I want to add pages to my Header Menu, there is the option 'Header Order' in the edit pages form.
But I realized, that the language code is not included in the generated URLs.
So if I am in my-site/fr, it changes to my-site/pages/page_name instead of my-site/fr/pages/page_name.
This seems not to be optimal for an multilingual website.

Would it make sense to change the url generation code?
I tried it for a bit and changed the code in the plugin.py
in line 54 in the build_pages_nav_main(*args) function
from:

      link = tk.h.literal(u'<a href="/{}/{}">{}</a>'.format(type_, name, title))

to:

from ckan.lib.helpers import lang
...

        current_lang = lang()
        link = tk.h.literal(u'<a href="/{}/{}/{}">{}</a>'.format(current_lang, type_, name, title))

so that the language code is part of the url.
My Code snippet is not optimal, because it always adds the language code, even if it is the default language.

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

No branches or pull requests

1 participant