Message text in JsDialogs not translated

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Message text in JsDialogs not translated

Postby samohtt » Thu Mar 04, 2021 10:05 am

Hi all,

one of our japanese customers complains about the standard JS Dialog when leaving the page, because the message text is in english independent on the browser language.
Technically this is implemented like this:

Code: Select all
window.onbeforeunload = function() {
  return 'This is an onbeforeunload message.';
}


It is also part of the cefclient dialog testpage (http://tests/dialogs) and interestingly the text in the JS code is not used at all.

I reproduced this with the latest available version with the following steps:

- cefclient.exe --lang=de (or any other language different to en)
- Check in the DEV tools console: navigator.language = de-DE
- Open the dialog test page => Tests - Other Tests - Dialogs
- Press any of the buttons and close the dialog (Show alert or Show Confirm)
- Press back button
=> JsDialog appears with "Is it ok to leave/reload the page"

I assume that the text is not part of the locale files and is somehow hardcoded.

My question is now:
Is it possible to get this built-in text translated by adding it into the locale files (as a bug/feature/improvement request) or is there any possibility to change the messagetext in the callback functions without implementing the whole custom dialog.
I tried in OnBeforeUnloadDialog but the parameter "message" cannot be overwritten. And OnJsDialog is only called for custom dialogs.

Thanks,
Thomas
samohtt
Techie
 
Posts: 20
Joined: Tue Jul 24, 2018 11:32 am

Re: Message text in JsDialogs not translated

Postby magreenblatt » Thu Mar 04, 2021 11:36 am

The message returned from onbeforeunload is discarded by Chromium so unfortunately we can't use it. You will need to implement CefJSDialogHandler::OnBeforeUnloadDialog in your application to show a custom dialog and message.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Message text in JsDialogs not translated

Postby magreenblatt » Thu Mar 04, 2021 11:41 am

Is it possible to get this built-in text translated by adding it into the locale files (as a bug/feature/improvement request) or is there any possibility to change the messagetext in the callback functions without implementing the whole custom dialog.

We don't provide translations for CEF-specific strings. The Chromium dialog has a title of "Leave site?" (IDS_BEFOREUNLOAD_MESSAGEBOX_TITLE) and "Changes you made may not be saved." (IDS_BEFOREUNLOAD_MESSAGEBOX_MESSAGE), which isn't ideal either.

We could add a CEF string with English-only text and allow you to override the value via CefResourceBundleHandler::GetLocalizedString. You're welcome to add a feature request for that, and submit a PR if you're up to implementing it.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 56 guests