Just checked the plugin settings again and found a setting for default formality level which I set to formal. But then the same error comes up as noted above and I’m unable to access this settings page now.
Also the select dropdown field labels are totally empty. Values are set but since there’s no label, the fields seem empty even though they’re selectable.
I added the Polylang locale de_DE_formal (I had no DE locale set up before on my site)
The DE language is set to formal in my DeepL settings.
I created a German article from a French article, saved the draft, then translated from FR to DE.
I had no problem.
To solve potential conflicts, I added a function to stripe the _formal or_informal suffix of Polylang locales in the context of the WPDeepL behaviour.
v2.3.3 has been uploaded and should solve your problem
Thanks for your fast response. But this raises another issue after updating:
production.ERROR: substr(): Argument #2 ($offset) must be of type int, string given {"userId":1,"exception":"[object] (TypeError(code: 0): substr(): Argument #2 ($offset) must be of type int, string given at /site/public/wp-content/plugins/wpdeepl/deepl-configuration.class.php:108)
I’d suggest to use str_replace() instead of substr() here.
Did that to fix it temporarily for my local test site and tried to translate again: https://jmp.sh/SvmB6ad1
This gives this warning then:
production.ERROR: Array to string conversion {"userId":1,"exception":"[object] (ErrorException(code: 0): Array to string conversion at /site/public/wp-content/plugins/wpdeepl/client/deeplapi-translate.class.php:154)
And still, the language select boxes on settings page seem to be empty:
https://jmp.sh/iWZx4K4l
Sorry to bother again. In order to check if it’s only happening on certain steps involved I proceeded the way you wrote earlier:
I created a German article from a French article, saved the draft, then translated from FR to DE.
I had no problem.
I added a native english content then duplicated that content for a german translation, saved this as draft but had the exact same error.
BTW: I found that when saving a draft the plugin’s metabox tells me to save or publish the post first (via block editor). Need to reload the editor view in order to show the translation interface.
This error :
production.ERROR: substr(): Argument #2 ($offset) must be of type int, string given {"userId":1,"exception":"[object] (TypeError(code: 0): substr(): Argument #2 ($offset) must be of type int, string given at /site/public/wp-content/plugins/wpdeepl/deepl-configuration.class.php:108)
show a problem with your installation. It’s situated just after get_locale()
$locale = get_locale();
if( strpos( $locale, '_formal' ) != false ) {
108: $locale = substr( '_formal', '', $locale );
}
get_locale should always return a string.
Could you list your plugins and/or your custom setup ?
Hey,
no problem with the return value of get_locale(), I get a valid string “de_DE_formal”.
It’s actually this line in your code which is causing trouble:
$locale = substr( '_formal', '', $locale );
please check https://www.php.net/manual/en/function.substr for reference. 2nd parameter ($offset) needs to be string.
So I fixed it for me like this:
$locale = str_replace('_formal', '', $locale );
Ok, and then there’s another small issue. The selected languages on settings page are correctly translated but those in the editor UI are not:
https://jmp.sh/YM5bqwOS
https://jmp.sh/UYx0fand
Hey, any news in this regard? The issue is not really resolved…
That was a brain fart. Fixed in 2.3.5
Thanks!
Still having this problem with empty language select boxes in plugin settings then (https://jumpshare.com/v/SEl5yTmdWwCdoBIzK72P) and this thing:
Ok, and then there’s another small issue. The selected languages on settings page are correctly translated but those in the editor UI are not:
https://jmp.sh/YM5bqwOS
https://jmp.sh/UYx0fand