function TranslationsStream::basePath

Same name and namespace in other branches
  1. main core/modules/locale/src/StreamWrapper/TranslationsStream.php \Drupal\locale\StreamWrapper\TranslationsStream::basePath()

Returns the base path for translations://.

Return value

string|null The base path for translations://.

5 calls to TranslationsStream::basePath()
LocaleHooks::formSystemFileSystemSettingsAlter in core/modules/locale/src/Hook/LocaleHooks.php
Implements hook_form_FORM_ID_alter() for system_file_system_settings().
LocaleSettingsForm::buildForm in core/modules/locale/src/Form/LocaleSettingsForm.php
Form constructor.
locale_install in core/modules/locale/locale.install
Implements hook_install().
locale_translate_get_interface_translation_files in core/modules/locale/locale.bulk.inc
Get interface translation files present in the translations directory.
TranslationsStream::getDirectoryPath in core/modules/locale/src/StreamWrapper/TranslationsStream.php
Gets the path that the wrapper is responsible for.

File

core/modules/locale/src/StreamWrapper/TranslationsStream.php, line 65

Class

TranslationsStream
Defines a Drupal translations (translations://) stream wrapper class.

Namespace

Drupal\locale\StreamWrapper

Code

public static function basePath() {
  if ($config_path = \Drupal::config('locale.settings')->get('translation.path')) {
    return $config_path;
  }
  $file_system = \Drupal::service(FileSystemInterface::class);
  $path = Settings::get('locale_translation_path', 'public://translations');
  // Stream wrappers such as public:// must be resolved explicitly, fall back
  // to the original path where realpath() fails.
  if ($realpath = $file_system->realpath($path)) {
    return $realpath;
  }
  return $path;
}

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