From c198fb8c24b4b695cc7b28254e2a3e0028e9d5bb Mon Sep 17 00:00:00 2001 From: Aleksandar Gajic Date: Wed, 10 Jan 2024 07:27:08 +0000 Subject: [PATCH] [FW][FIX] website: make multirange widget works with sr@latin lang code The range widget doesn't work with Serbian language, because language locale subtag contains `@`. Steps to reproduce: 1. Activate Serbian Latin language (sr@latin) on your website 2. Go to /shop 3. Switch to Serbian lang The price ranger slider (which can be disabled) will throw this TB: "RangeError: Incorrect locale information provided". The fix is to do as other places in the code: replace this specific lang code with the expected one. Ideally, a util method should be used at all those places. closes odoo/odoo#148593 Forward-port-of: odoo/odoo#148279 Signed-off-by: Romain Derie (rde) --- addons/website/static/lib/multirange/multirange_custom.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/website/static/lib/multirange/multirange_custom.js b/addons/website/static/lib/multirange/multirange_custom.js index c4864989f47..a091a87361a 100644 --- a/addons/website/static/lib/multirange/multirange_custom.js +++ b/addons/website/static/lib/multirange/multirange_custom.js @@ -264,7 +264,8 @@ export class Multirange { } formatNumber(number) { - const locale = document.querySelector("html").getAttribute("lang"); + const language = document.querySelector("html").getAttribute("lang"); + const locale = language === "sr@latin" ? "sr-Latn-RS" : language.replace(/_/g, "-"); let formatedNumber = number.toLocaleString(locale, { minimumFractionDigits: 2, maximumFractionDigits: 2,