p5.js-web-editor icon indicating copy to clipboard operation
p5.js-web-editor copied to clipboard

Incorrect value of navigator.language property in the editor and fullscreen mode

Open piecesofuk opened this issue 4 years ago • 2 comments

Nature of issue?

  • Found a bug

Details about the bug:

I'm using the Chrome browser on a Chromebook Version 88.0.4324.186 (Official Build) (64-bit)

I wanted to test an api call that passed my browser's language and test it with other languages. I'm getting the language code from the navigator.language property. The default value of navigator.language is "en-GB". I installed a Chrome Locale Switcher extension to change this value. Whenever I switch locales I reload the sketch. When I tested my code I noticed that whatever language I changed the locale to, for example "fr", "en-GB" was always being passed to the api. I console logged the value in the p5 console and it showed "en-GB". However, if I open the Chrome dev tools and display the value of navigator.language it is shown as "fr". When I run the sketch in "present" mode, via the share option, the value of navigator.language is correctly returned as "fr". The incorrect value is also returned in "full" mode.

A simple snippet of code would be console.log(navigator.language);

piecesofuk avatar Feb 19 '21 20:02 piecesofuk

Thanks for reporting! I believe this is because the "editor" view and the "full" view are running the sketch in an iframe. If you look at the default index.html for a sketch, the language is set to "en". I think you would have to manually change the language in the index.html for this to work.

For security reasons, the extension won't have access to change the language in the sketch directly. However, it probably makes sense to update the default language of the sketch based on the user's locale, or the language they have set in the web editor.

catarak avatar Mar 02 '21 23:03 catarak

Can I contribute to this issue? I'm new here, but I have experience contributing to many other organizations. Is there a Discord channel or any other channel where I can discuss and get assistance?

nick2432 avatar Dec 20 '23 04:12 nick2432