You are here

function locale_install in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/locale/locale.install \locale_install()
  2. 5 modules/locale/locale.install \locale_install()
  3. 6 modules/locale/locale.install \locale_install()
  4. 7 modules/locale/locale.install \locale_install()
  5. 9 core/modules/locale/locale.install \locale_install()

Implements hook_install().

File

core/modules/locale/locale.install, line 16
Install, update, and uninstall functions for the Locale module.

Code

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);
}