Hi Max, I read your post about the multi-lingual support, it had website as well. Please can you tell me more about it. I am about to start the multi-lingual website project so if that is something you are already doing then I will stop right now.
Since I enabled the Translation in a record-level for ERPNext, and frappe, I take care of enable jinja templates translation also.
In the multi-lingual request you will be able to translate almost all field contents, so let’s think in Website Page.
The requirements to turn one WebSite multi-lingual are:
Enable translation in to Content Fields (By Default, I already make a patch for that, but patch dont work for new instances)
Translate all the page content, to the target languages, in case of an tranlation of an “Text Editor”, each HTML tag into the translatded content matter.
Let suppose:
en: Original Text
pt-BR: Texto Original
es: Contenido Original
Build an localization Menu, on the menu, you only need to pass an URL argument _lang= with the target language, eg: to translate the website to Brazilian Portuguese, http://mysite.com?_lang=pt-BR
@KanchanChauhan, I dont think you got nothing wrong, I think that the issue is regard of the changes that netchampfaris made into the project to merge it into the core.
Look this
And this
Various aspects of my original code, that ensure the multi-lingual behavior, have been removed, by netchampfaris on pull request acceptation.
Sorry, for this, but I make my post, with the features that I already delivered for frappe, not in basis of what was accepted and what was not.
yeah I saw that, your patch is also removed to update existing fields.
So I was able to get the translation working in website.
My next question is how do we translate the menus and also the URL. We will need a language selector as well. I will work these things and connect with you to discuss further if that is ok with you.
Someone know if we can use url redirection with nginx to get website translation work. I mean is it possible to configure nginx for when user add /en/ or /fr/ it will add parameters _lang in url automatically?
Do we have any documentation link for this “Multilingual PR split into small features” because I can’t visually see this multilingual stuff appearing anywhere in the system? Using v10.1.28 (master).
Hi Max, it has been a long time but I can report what @KanchanChauhan described in his post with photos worked for me in ERPNext 14. I am actually loving it!
I added the following code to the website script to change website language and remember the choice with a cookie. With this code and the Translation solution I can get everything I have inside brackets translated on the webpages I create like {{_(“Some text I want to translate.”) }}
// add language picker in navbar
$("#navbarSupportedContent").after("<select id='language-select' class='form-control' style='margin-left: 10px; width: auto;'><option value='en'>English</option><option value='de'>Deutsch</option></select>");
// get the preferred language in this session and set it on the language picker
var preferred_language = frappe.get_cookie("preferred_language");
if (preferred_language){
$('#language-select').val(preferred_language);
}
// whenever the language changes, redirect to its corresponding page in the other language
$('#language-select').on('change', function() {
frappe.call("frappe.translate.set_preferred_language_cookie", {
preferred_language: this.value
}).then(function() {
var preferred_language = frappe.get_cookie("preferred_language");
var english_translation = window.location.href.split("?").shift().split("/").pop() + '?_lang=en'; // add the path to the english translation
var german_translation = window.location.href.split("?").shift().split("/").pop() + '?_lang=de'; // add the pathto the german translation
if (preferred_language === "en" && english_translation){
window.location = english_translation;
} else if (preferred_language === "de" && german_translation){
window.location = german_translation;
}
});
});
var english_translation = window.location.href.split("?").shift().split("/").pop() + '?_lang=en'; // add the path to the english translation
var german_translation = window.location.href.split("?").shift().split("/").pop() + '?_lang=de'; // add the pathto the german translation
if(preferred_language === "en" && window.location.href.split("?").pop() !== "_lang=en" ){
window.location.href = english_translation;
} else if (preferred_language === "de" && window.location.href.split("?").pop() !== "_lang=de" ){
window.location.href = german_translation;
}
My question is, although this method of translation works for most things, can I use it to translate Footer items I arrange in the Website Settings?
This format there doesn’t work {{_(“Privacy Policy”) }}
I realized in ErpNext Version 14, this convention for translations doesnt work on every doctype and on other forum posts people also mention it.
It works for webpages doc type and I can translate things with it but for example homepage sections doctype isn’t supported.
I don’t have enough programming knowledge to know how to fix it but a quick fix for me will probably be create another webpage name it home and try to make it the default landing page somehow for now.
But also custom website navbar items isn’t being translated and I don’t know how to fix that. Custom like “About Us”. Apart from that default navbar items like “Products” are translated