Try ERPNext Buy Support Partners Foundation

Multilanguage website

Hi everybody. Thanks again for all your effort with this wonderful piece of software.

About using and setting up a multilanguage website with Frappe. I have found some “issues” but I need to confirm them with you before make a fix for them.

Facts:

  • Frappe site, will use user browser language as default language.

  • Language can be changed permanently only if user is registered.

  • Language can be changed for “actual page”, passing “_lang=XX” to requested url.

    • As “Guest” user, when other link is clicked, next page will be again with default browser language.
    • As “Logged” user, next page will be with into language defined into user preferences

Example of use:

  • For example, browser with Spanish as main language and I want to navigate (as Guest = all internet site visitors) into English.

  • When page is loaded with “?_lang=en”, “frappe.local.lang” is updated with its value into /apps/frappe/frappe/auth.py

  • Translatable fields are working properly because method “_()” uses “frappe.local.lang”

    • 1st issue. Multilanguage page (two folders en/index.html and es/index.html) used by “render_page_by_language(path)” method fails. It will not render “en/index.html” page because it uses “guest_language()” which uses browser language to get language.

    • 2nd issue. If I continue navigating site, next page will be in Spanish again (due to my main browser language).

Needs:

  • For “Guest” users case, if “?_lang=XX” is used, we should “keep” that language change along site navigation, at least for that session.

  • For “logged” users case, if “?_lang=XX” is used, we should “update” user language preference. Maybe using other parameter like “_set_lang=XX”, to avoid being affected by cases like printing document in another language, for example.

  • Make clearer into documentation the use of “translated_languages_for_website” hook, used by “render_page_by_language(path)” method. It defines website available languages, so site will not be accessible in languages not added there.

I am going to try to “solve” these issues, but, please, I need your feedback to be sure, I am not wrong or I am missing something important here :slight_smile:

Thank you very much to everybody for your help.

1 Like

Hi,

I have the same issue. I really like to be able to set a fixed language for guest users. How can this be achieved?

Thank you!