diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleFileImportStatus.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleFileImportStatus.php index 2126b26..e7b3b94 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleFileImportStatus.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleFileImportStatus.php @@ -72,8 +72,8 @@ class LocaleFileImportStatus extends WebTestBase { * A file object of type stdClass. */ function mockImportedPoFile($langcode, $timestamp_difference = 0) { - $dir = variable_get('locale_translate_file_directory', drupal_get_path('module', 'locale') . '/tests'); - $testfile_uri = $dir . '/test.' . $langcode . '.po'; + $dir = variable_set('locale_translate_file_directory', drupal_get_path('module', 'locale') . '/tests'); + $testfile_uri = 'translations://test.' . $langcode . '.po'; $file = locale_translate_file_create($testfile_uri); $file->original_timestamp = $file->timestamp; @@ -187,7 +187,7 @@ class LocaleFileImportStatus extends WebTestBase { variable_set('locale_translate_file_directory', $dir); $langcode = 'de'; $this->addLanguage($langcode); - $file_uri = $dir . '/po_' . $this->randomName() . '.' . $langcode . '.po'; + $file_uri = 'translations://po_' . $this->randomName() . '.' . $langcode . '.po'; file_put_contents($file_uri, $this->randomName()); $this->assertTrue(is_file($file_uri), 'Translation file is created.'); language_delete($langcode); diff --git a/core/modules/locale/lib/Drupal/locale/TranslationsStream.php b/core/modules/locale/lib/Drupal/locale/TranslationsStream.php new file mode 100644 index 0000000..975c184 --- /dev/null +++ b/core/modules/locale/lib/Drupal/locale/TranslationsStream.php @@ -0,0 +1,37 @@ +getTarget()); + return $GLOBALS['base_url'] . '/' . self::getDirectoryPath() . '/' . drupal_encode_path($path); + } +} diff --git a/core/modules/locale/locale.bulk.inc b/core/modules/locale/locale.bulk.inc index f795f99..896f9f7 100644 --- a/core/modules/locale/locale.bulk.inc +++ b/core/modules/locale/locale.bulk.inc @@ -278,7 +278,14 @@ function locale_translate_batch_import_files($langcode = NULL, $finish_feedback */ function locale_translate_get_interface_translation_files($langcode = NULL) { $directory = variable_get('locale_translate_file_directory', conf_path() . '/files/translations'); - return file_scan_directory($directory, '!' . (!empty($langcode) ? '\.' . preg_quote($langcode, '!') : '') . '\.po$!', array('recurse' => FALSE)); + $return = file_scan_directory($directory, '!' . (!empty($langcode) ? '\.' . preg_quote($langcode, '!') : '') . '\.po$!', array('recurse' => FALSE)); + + foreach ($return as $filepath => $file) { + $file->uri = 'translations://' . $file->filename; + $return[$file->uri] = $file; + unset($return[$filepath]); + } + return $return; } /** @@ -358,7 +365,7 @@ function locale_translate_batch_finished($success, $results) { function locale_translate_file_create($filepath) { $file = new stdClass(); $file->filename = drupal_basename($filepath); - $file->uri = $filepath; + $file->uri = 'translations://' . $file->filename; $file->timestamp = filemtime($file->uri); return $file; } diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index ce20b59..2fc097a 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -12,6 +12,7 @@ */ use Drupal\locale\LocaleLookup; +use Drupal\locale\TranslationsStream; /** * Regular expression pattern used to localize JavaScript strings. @@ -170,6 +171,21 @@ function locale_theme() { } /** + * Implements hook_stream_wrappers(). + */ +function locale_stream_wrappers() { + $wrappers = array( + 'translations' => array( + 'name' => t('Translation files'), + 'class' => 'Drupal\locale\TranslationsStream', + 'description' => t('Translation files'), + 'type' => STREAM_WRAPPERS_LOCAL_NORMAL, + ), + ); + return $wrappers; +} + +/** * Implements hook_language_insert(). */ function locale_language_insert($language) {