- ๐บ๐ธUnited States smustgrave
Hiding the file to avoid confusion.
Not sure if this is the correct solution though. Shouldn't we figure out what is passing null?
Whatever the solution it will need a test case to show the issue is solved.
- ๐ฎ๐นItaly apaderno Brescia, ๐ฎ๐น
Passing an empty string to
strtr()
is useless, as no replacement will be done. Type hinting the first parameter ofstrtr()
tostring
would help more; at least PHP would throw an exception that allows to understand what causes the problem.(I agree: We should figure out what exactly is causing this issue; at least we are interested to know if it can reproduced on a plain Drupal installation.)
- ๐บ๐ธUnited States les lim
In our case, we're using Locale module, but the configuration in locale.settings.yml is not installed. Just looking through our git history, I'm not sure it ever has been.
This hadn't been causing us any problems that we knew of until the PHP 8.1 upgrade. During locale_requirements(), the function locale_translation_source_build() is called for each project and attempts to build a filepath to a local .po file for the project. To do this, it uses a default filename pattern that is defined in locale.settings.yml. If you don't have any locale.settings configuration, strtr() gets passed NULL instead of a filename pattern.
Not having any locale.settings is clearly a bug on our side, but it sounds like we're not the only ones this has happened to. I'm happy to resolve our bad config state, but should there be safeguards here to account for this edge case?
- leymannx Berlin
Missing locale.settings.yml in the config/sync dir here too. Not sure how it ended up like that. Even going to /admin/config/regional/translate/settings and saving the form to create the locale.settings.yml doesn't fix the problem. Some keys were still missing from it.
Easiest was to simply run
cp web/core/modules/locale/config/install/locale.settings.yml config/sync/locale.settings.yml && drush cim
and the error was gone. I have faced exactly the same issue described above, and can confirm it's a config issue where not all keys were in the yml file.
Just as #10 mentioned, the fix is to use the base config as a starting point - either copy it in your config folder or just single-file import it and adjust as necessary.- ๐ช๐ธSpain qpro Spain
Same issue as #10 and #12
Apart from error
"Deprecated function: strtr(): Passing null to parameter #1 ($string) of type string is deprecated in locale_translation_build_server_pattern() (line 323 of core/modules/locale/locale.translation.inc)"
also this one
"TypeError: Drupal\locale\Form\LocaleSettingsForm::Drupal\locale\Form\{closure}(): Argument #1 ($overwrite_customized) must be of type bool, null given, called in /var/www/html/comg/web/core/lib/Drupal/Core/Form/ConfigTarget.php on line 187 in Drupal\locale\Form\LocaleSettingsForm->Drupal\locale\Form\{closure}() (line 82 of core/modules/locale/src/Form/LocaleSettingsForm.php)."
Based on #10 & #12, I fixed with:
drush cim --partial --source=/var/www/html/site/<custom directory>
with locale.settings.yml inside (without --partial option you could delete the rest of configurations)(Drupal 10.2.5 & PHP 8.1.2)
- ๐บ๐ธUnited States uri_frazier Portland, Oregon
I got the same error when visiting /admin/config/regional/translate/settings:
"TypeError: Drupal\locale\Form\LocaleSettingsForm::Drupal\locale\Form\{closure}(): Argument #1 ($overwrite_customized) must be of type bool, null given, called in /var/www/html/comg/web/core/lib/Drupal/Core/Form/ConfigTarget.php on line 187 in Drupal\locale\Form\LocaleSettingsForm->Drupal\locale\Form\{closure}() (line 82 of core/modules/locale/src/Form/LocaleSettingsForm.php)."
Was able to resolve using the fix mentioned in #10 ๐ strtr(): Passing null to parameter #1 ($string) of type string is deprecated in locale_translation_build_server_pattern() Needs work
cp web/core/modules/locale/config/install/locale.settings.yml config/sync/locale.settings.yml && drush cim
(Drupal 10.2.6 & PHP 8.1.2)
- ๐ฎ๐ณIndia vinmayiswamy
Hi, I attempted to reproduce this issue by following the steps below:
- Installed Drupal version 10.2.8-dev (cloned from 10.2.x).
- PHP version 8.1.29.
- Enabled the "locale" module.
- Noticed that the locale.settings.yml file is not created automatically after enabling the module.
- Was able to visit the /admin/config/regional/translate/settings page and save the settings form without encountering any issues.
- As mentioned in previous comments (#10, #12, #13 and #14), I copied the locale.settings.yml file with the command
cp core/modules/locale/config/install/locale.settings.yml sites/default/files/sync/locale.settings.yml
and executeddrush cim
. - Revisited the /admin/config/regional/translate/settings page and saved the settings form without any issues.
I also tested the same steps in Drupal versions 10.3.2 and 11.x with PHP 8.3 and did not replicate the issue.
If there are any specific steps or additional details I might have missed, please let me know. I would greatly appreciate any guidance.
Thanks!
- leymannx Berlin
Yes, a config file does not get created automagically just by enabling a module.