Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
822 Переглядів

Hi all,

following problem in my case:
We have a custom language in odoo with a custom locale 'tech'.

Everything worked fine in odoo 13 with I guess "moment.js" (if i´m correct) and locale definition.

We could override the field "lang" in python code and everything worked fine.

Now luxon was introduced in v16 and I get an error in 

    _proto4.isEnglish = function isEnglish() {

      return this.locale === "en" || this.locale.toLowerCase() === "en-us" || new Intl.DateTimeFormat(this.intl).resolvedOptions().locale.startsWith("en-us");

    };

Cause now my locale is "tech" and this is not a official locale setting.

I would like to override the "isEnglish()" function to check if locale == 'tech' then set locale == 'en', that would work fine in our case.


How can I override this static lib js correctly?

Аватар
Відмінити
Автор Найкраща відповідь

Hey cybrosis,

thank you a lot for your suggestion, I will try this out.

My current fix was to completely replace the assets via manifest and fix it in the lines, 

but I would prefer a solution like yours to keep it more clean.


Best Regards

Аватар
Відмінити
Найкраща відповідь

Hi,

Try this code:

luxon.DateTime.prototype.isEnglish = function isEnglish() {

        // Override the isEnglish() function to handle the 'tech' locale as 'en'

        return this.locale === "en" || this.locale.toLowerCase() === "en-us" || new Intl.DateTimeFormat(this.intl).resolvedOptions().locale.startsWith("en-us") || this.locale === "tech";

    };


Hope it helps

Аватар
Відмінити