function locale_install

Same name in other branches
  1. 7.x modules/locale/locale.install \locale_install()
  2. 9 core/modules/locale/locale.install \locale_install()
  3. 8.9.x core/modules/locale/locale.install \locale_install()
  4. 11.x core/modules/locale/locale.install \locale_install()

Implements hook_install().

File

core/modules/locale/locale.install, line 16

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);
    $t_args = [
        ':translate_status' => base_path() . 'admin/reports/translations/check?destination=' . urlencode(base_path() . 'admin/reports/translations'),
    ];
    $message = t('Check <a href=":translate_status">available translations</a> for your language(s).', $t_args);
    \Drupal::messenger()->addStatus($message);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.