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

Error when using window._() localization in documentReady hook #6627

Open
brunob opened this issue Sep 4, 2024 · 11 comments · Fixed by #6634
Open

Error when using window._() localization in documentReady hook #6627

brunob opened this issue Sep 4, 2024 · 11 comments · Fixed by #6634

Comments

@brunob
Copy link
Contributor

brunob commented Sep 4, 2024

Describe the bug

Using window._() localization function in a script called by documentReady hook generate an error TypeError: window._ is not a function.

To Reproduce
Steps to reproduce the behavior:

  1. Installe https://framagit.org/framasoft/Etherpad/ep_delete_after_delay/ plugin
  2. Load an existing pad
  3. See the "An error occurred" window

Server (please complete the following information):

  • Etherpad version: 2.2.2
  • OS: Ubuntu 20.04
  • Node.js version (node --version): v20.17.0
  • npm version (npm --version): 10.8.2
  • Is the server free of plugins: only the ep_delete_after_delay plugin

Desktop (please complete the following information):

  • OS: Ubuntu 20.04
  • Browser Firefox
  • Version 129.0.2

Additional context

Bur reported on plugin repo here https://framagit.org/framasoft/Etherpad/ep_delete_after_delay/-/issues/23 but it seems to be an etherpad regression.

@SamTV12345 SamTV12345 linked a pull request Sep 5, 2024 that will close this issue
@brunob
Copy link
Contributor Author

brunob commented Sep 6, 2024

@SamTV12345 this fix the error but now it generate a warning "No translations available (yet)" :\

@SamTV12345 SamTV12345 reopened this Sep 6, 2024
@SamTV12345
Copy link
Member

Ok then there is another problem. Maybe a fork would solve the issues. @ldidry Do you have an idea why the plugin is not working?

@ldidry
Copy link
Contributor

ldidry commented Sep 6, 2024

No, but I didn’t tried to reproduce the bug (no time for that right now).

@brunob
Copy link
Contributor Author

brunob commented Sep 6, 2024

FTR, it worked on v2.1.0 and it's stated to be broken on 2.2.0.

If i log translations from https://github.com/ether/etherpad-lite/blob/develop/src/static/js/vendors/html10n.ts#L691 i can see the ep_delete_after_delay items in it for all the calls that concern an item from etherpad core eg pad.userlist.entername. But, when the item come from ep_delete_after_delay translations var is undefined.

@SamTV12345
Copy link
Member

FTR, it worked on v2.1.0 and it's stated to be broken on 2.2.0.

If i log translations from https://github.com/ether/etherpad-lite/blob/develop/src/static/js/vendors/html10n.ts#L691 i can see the ep_delete_after_delay items in it for all the calls that concern an item from etherpad core eg pad.userlist.entername. But, when the item come from ep_delete_after_delay translations var is undefined.

Thanks I'll debug it . I guess this is an issue on Etherpad

@brknkfr
Copy link

brknkfr commented Sep 28, 2024

@SamTV12345, did you have time to debug this?

@SamTV12345
Copy link
Member

@SamTV12345, did you have time to debug this?

Yes the fix is relatively easy. The plugin needs to substitute any occurrence with the html10n.get() expression and it will work.

@brknkfr
Copy link

brknkfr commented Sep 29, 2024

Ah, I don't really know how to program in javascript, but you mean all the occurrences of _ (underscore) have to be replaced by html10n.get(). Correct? I'll probably create a PR.

@SamTV12345
Copy link
Member

Ah, I don't really know how to program in javascript, but you mean all the occurrences of _ (underscore) have to be replaces by html10n.get(). Correct? I'll probably create a PR.

Yes you need to import the Etherpad module and then call html.get with the correct value. I have no idea why the underscore does not work. Could be that the bundler optimized things incorrectly.

@dcht00
Copy link
Collaborator

dcht00 commented Oct 14, 2024

Just checking: Was this solved? Changelog mentions something like this. And I think I noticed a problem with this while testing previous versions, but now it seems gone.

@SamTV12345
Copy link
Member

Just checking: Was this solved? Changelog mentions something like this. And I think I noticed a problem with this while testing previous versions, but now it seems gone.

I have no idea what JavaScript does here. It is normally just a shortcut. The .get() version works. ._ does not.

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.

7 participants
@brunob @ldidry @dcht00 @brknkfr @SamTV12345 and others