- Issue created by @Chase.
I am trying to set the translation directory path in settings.php
, like this:
$config['locale.settings']['translation']['path'] = '/var/www/d10/files/translations';
This works and the path is used by the locale module.
Unfortunately, the corresponding input field in admin/config/media/file-system
is empty. This means the user cannot save the form, for example to save other options.
This is because in locale_form_system_file_system_settings_alter()
'#default_value' => \Drupal::configFactory()->getEditable('locale.settings')->get('translation.path'),
returns the empty string instead of the path set in settings.php
.
Set the translation directory path in settings.php
on a fresh install before enabling locale module as shown above. Enable locale module and open admin/config/media/file-system
.
I am not sure if I'm setting the path in the correct way, that's why I'm tagging this as Support request for now. But maybe the following code in locale.install
has to be changed?
/**
* Implements hook_install().
*/
function locale_install() {
// Create the interface translations directory and ensure it's writable.
if (!$directory = \Drupal::config('locale.settings')->get('translation.path')) {
$site_path = \Drupal::getContainer()->getParameter('site.path');
$directory = $site_path . '/files/translations';
\Drupal::configFactory()->getEditable('locale.settings')->set('translation.path', $directory)->save();
}
\Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
}
Instead:
/**
* Implements hook_install().
*/
function locale_install() {
// Create the interface translations directory and ensure it's writable.
if (!$directory = \Drupal::config('locale.settings')->get('translation.path')) {
$site_path = \Drupal::getContainer()->getParameter('site.path');
$directory = $site_path . '/files/translations';
}
\Drupal::configFactory()->getEditable('locale.settings')->set('translation.path', $directory)->save();
\Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
}
Clear up whether I'm understanding the settings.php
override system correctly. Decide the correct way to make the translation path overridable. Create a patch file, if applicable.
The translation path in admin/config/media/file-system
could be changed to an unchangeable display string instead of an input field like the public, private and temp directories above it, when it's overriden in settings.php.
Active
10.2 β¨