Open MdreW opened 9 months ago
@peppelinux , I have written a simple demo for a errors page single with localization, is a really simple js. In this example I have added a single error (code 100) and I have added the ID 'error' at the page box.
errors.js
const localizations = {
'it': {
'100': 'Autenticazione fallita'
},
'en': {
'100': 'Authentication fail'
}
}
document.addEventListener("DOMContentLoaded", () => {
let default_locale = 'it'
let available_locales = ['it','en']
let params = new URLSearchParams(window.location.search)
let locale = available_locales.includes(params.get('locale')) ? params.get('locale') : default_locale ;
let element = document.getElementById('error')
if (localizations[locale][params.get('error')]) {
element.innerHTML = localizations[locale][params.get('error')]
}
});
Without options return the standard error page /static/error_page.html
If I add the error
option in the url and the error is present in the localization the page will be updated /static/error_page.html?error=100
Optionally I ca add also the locale option /static/error_page.html?locale=en&error=100
We can also detach the localization from the error.js, in a single locale json or with different json file for each locale. At this moment we have 24 different errors messages (SPID), I not know the wallet error prerequisite. Write more different files is cute but not mandatory.
What do you think about it?
@MdreW very interesting feature
I'd like to have it in 2.1.0 together with i18n in pyeudiw
if you can go ahead with a PR we'll get it in time, we won't change the templates in this version 2.0.0
Ok, I will work for this :+1:
New proposal for errors page.
Use the same errors page for all errors and add more detail and localization with javascript.
For security reason the errors details can't be add from with a simple string, but must be decoded from the error's code.
With a javascript we read a json with all codes and his error details and add this in the error box.
Vantage:
example json: