Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cancel switch off pop-up not showing #318

Closed
ch3p4ll3 opened this issue Oct 17, 2024 · 16 comments · Fixed by #307
Closed

Cancel switch off pop-up not showing #318

ch3p4ll3 opened this issue Oct 17, 2024 · 16 comments · Fixed by #307

Comments

@ch3p4ll3
Copy link
Contributor

if I remember correctly, a pop-up once came up so that the countdown could be stopped if the relay is set to turn off at the end of a print job.

The pop-up is not displayed and this error comes up in the console:

packed_core.js?59b6a2d1:1879 Error calling onDataUpdaterPluginMessage on view model OctoRelayViewModel : Incorrect locale information provided
RangeError: Incorrect locale information provided
    at new NumberFormat (<anonymous>)
    at formatDeadline (http://10.188.26.141:5000/static/webassets/packed_plugins.js?d298bfc0:31932:37)
    at showHints (http://10.188.26.141:5000/static/webassets/packed_plugins.js?d298bfc0:32049:30)
    at OctoRelayViewModel.onDataUpdaterPluginMessage (http://10.188.26.141:5000/static/webassets/packed_plugins.js?d298bfc0:32097:11)
    at callViewModelIf (http://10.188.26.141:5000/static/webassets/packed_core.js?59b6a2d1:1878:75)
    at http://10.188.26.141:5000/static/webassets/packed_core.js?59b6a2d1:1872:138
    at Pn (http://10.188.26.141:5000/static/webassets/packed_libs.js?409a9b49:30:530)
    at Function.<anonymous> (http://10.188.26.141:5000/static/webassets/packed_libs.js?409a9b49:51:66)
    at callViewModelsIf (http://10.188.26.141:5000/static/webassets/packed_core.js?59b6a2d1:1872:95)
    at callViewModels (http://10.188.26.141:5000/static/webassets/packed_core.js?59b6a2d1:1871:56)
@RobinTail
Copy link
Collaborator

that's interesting

@RobinTail
Copy link
Collaborator

RobinTail commented Oct 18, 2024

  1. could you check the value of LOCALE in browser console, @ch3p4ll3 ?

image

  1. what is your browser? version?

@RobinTail
Copy link
Collaborator

RobinTail commented Oct 18, 2024

LOCALE comes from backend into the initial template
https://github.com/OctoPrint/OctoPrint/blob/ad9ebcaa0ef91950652fb2561b7c06b79d95a455/src/octoprint/templates/initscript.jinja2#L30
but technically, it's not really required, because Intl.NumberFormat() can operate with locale (first argument) set to undefined. In that case it will use the default browser locale.

@ch3p4ll3
Copy link
Contributor Author

  1. could you check the value of LOCALE in browser console, @ch3p4ll3 ?

image

2. what is your browser? version?
  1. The locale is set to en, but that's not the browser I use usually with octoprint
  2. currently I'm using Firefox 128.3.1 on debian, usually I'm on Win11 with the latest chrome version

I don't know if it helps but in the pc I usually use(the one with W11) I have the system language in English but some regional settings(like time/date format, keyboard layout, etc...) in Italian

@RobinTail
Copy link
Collaborator

RobinTail commented Oct 18, 2024

The locale is set to en

hmmm...
It's strange that it does not work, @ch3p4ll3

if you sure that LOCALE (the particular global variable when you open OctoPrint) is set to en, then could you please run the following code the console of that browser:

new Intl.NumberFormat('en', {
    style: "unit",
    unitDisplay: "long",
    minimumFractionDigits: 1,
    maximumFractionDigits: 1,
    unit: "minute"
  }).format(5)

the output should be 5.0 minutes

and if it fails, also try this one:

new Intl.NumberFormat(undefined, {
    style: "unit",
    unitDisplay: "long",
    minimumFractionDigits: 1,
    maximumFractionDigits: 1,
    unit: "minute"
  }).format(5)

@ch3p4ll3
Copy link
Contributor Author

The locale is set to en

hmmm... It's strange that it does not work, @ch3p4ll3

if you sure that LOCALE (the particular global variable when you open OctoPrint) is set to en, then could you please run the following code the console of that browser:

new Intl.NumberFormat('en', {
    style: "unit",
    unitDisplay: "long",
    minimumFractionDigits: 1,
    maximumFractionDigits: 1,
    unit: "minute"
  }).format(5)

the output should be 5.0 minutes

and if it fails, also try this one:

new Intl.NumberFormat(undefined, {
    style: "unit",
    unitDisplay: "long",
    minimumFractionDigits: 1,
    maximumFractionDigits: 1,
    unit: "minute"
  }).format(5)

Yep, the output is correct in both cases, this evening I'll try on my main PC

@RobinTail
Copy link
Collaborator

RobinTail commented Oct 18, 2024

the output is correct in both cases

Then I don't understand the cause for the error.
Or maybe LOCALE is not en, but something else.

@RobinTail
Copy link
Collaborator

The only way to achieve that error is having incorrect value of LOCALE

@RobinTail
Copy link
Collaborator

But I'm going to apply my fix for that case and we'll see how it will work for you, @ch3p4ll3
Please wait...

@RobinTail RobinTail mentioned this issue Oct 18, 2024
@RobinTail
Copy link
Collaborator

@ch3p4ll3 , please try to install version 5.0.3rc1 from the Prerelease channel, or using this URL:

https://github.com/borisbu/OctoRelay/releases/download/5.0.3rc1/release.zip

Let me know if it fixes the issue.

@ch3p4ll3
Copy link
Contributor Author

@ch3p4ll3 , please try to install version 5.0.3rc1 from the Prerelease channel, or using this URL:

https://github.com/borisbu/OctoRelay/releases/download/5.0.3rc1/release.zip

Let me know if it fixes the issue.

So, I checked the locale on my main PC and it's it_IT, trying this code resulted in an exception:

new Intl.NumberFormat('it_IT', {
    style: "unit",
    unitDisplay: "long",
    minimumFractionDigits: 1,
    maximumFractionDigits: 1,
    unit: "minute"
  }).format(5)

Btw with this prerelease the problem is fixed. Ty

@RobinTail RobinTail reopened this Oct 18, 2024
@RobinTail
Copy link
Collaborator

Great. Yes, it_IT is incorrect locale format, it should be with a dash it-IT.
And the fix I made just ignores invalid locale.
I'm reopening this issue because the final version is not yet released.
Thank you very much for checking, @ch3p4ll3

@RobinTail
Copy link
Collaborator

RobinTail commented Oct 18, 2024

are you using this Italian localization pack by chance, @ch3p4ll3 ?
https://community.octoprint.org/t/translating-octoprint/21144/13
or something else that sets the LOCALE to it_IT ?

I just would like to understand the cause of that error better.

@ch3p4ll3
Copy link
Contributor Author

are you using this Italian localization pack by chance, @ch3p4ll3 ?

Nope

@ch3p4ll3
Copy link
Contributor Author

or something else that sets the LOCALE to it_IT ?

image
My octoprint language is set to "Autodetect from browser", Chrome is in english soo, idk

@RobinTail
Copy link
Collaborator

OK, thank you. In 5.1 (after we fix this issue) I will add another intermediate fallback that would try replacing _ with - to make it compatible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants