diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleFileImportStatus.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleFileImportStatus.php index 25d483d..fc09cab 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleFileImportStatus.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleFileImportStatus.php @@ -35,8 +35,14 @@ class LocaleFileImportStatus extends WebTestBase { $admin_user = $this->drupalCreateUser(array('administer site configuration', 'administer languages', 'access administration pages')); $this->drupalLogin($admin_user); - // Set the translation file directory. - variable_set('locale_translate_file_directory', drupal_get_path('module', 'locale') . '/tests'); + // Set the translation file directory to something writable. + $destination = conf_path() . '/files/translations';; + file_prepare_directory($dir, FILE_CREATE_DIRECTORY); + variable_set('locale_translate_file_directory', $destination); + + // Copy test po files to the same directory. + file_unmanaged_copy(drupal_get_path('module', 'locale') . '/tests/test.de.po', $destination, FILE_EXISTS_ERROR); + file_unmanaged_copy(drupal_get_path('module', 'locale') . '/tests/test.xx.po', $destination, FILE_EXISTS_ERROR); } /** diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php index 589c555..7d52b45 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php @@ -36,8 +36,14 @@ class LocaleImportFunctionalTest extends WebTestBase { function setUp() { parent::setUp(); - // Set the translation file directory. - variable_set('locale_translate_file_directory', drupal_get_path('module', 'locale') . '/tests'); + // Set the translation file directory to something writable. + $destination = conf_path() . '/files/translations';; + file_prepare_directory($dir, FILE_CREATE_DIRECTORY); + variable_set('locale_translate_file_directory', $destination); + + // Copy test po files to the same directory. + file_unmanaged_copy(drupal_get_path('module', 'locale') . '/tests/test.de.po', $destination, FILE_EXISTS_ERROR); + file_unmanaged_copy(drupal_get_path('module', 'locale') . '/tests/test.xx.po', $destination, FILE_EXISTS_ERROR); $this->admin_user = $this->drupalCreateUser(array('administer languages', 'translate interface', 'access administration pages')); $this->drupalLogin($this->admin_user); 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..3028a32 --- /dev/null +++ b/core/modules/locale/lib/Drupal/locale/TranslationsStream.php @@ -0,0 +1,34 @@ + array('po')); // Ensure we have the file uploaded. - if ($file = file_save_upload('file', $validators)) { + $destination = variable_get('locale_translate_file_directory', ''); + if ($file = file_save_upload('file', $validators, 'translations://')) { // Add language, if not yet supported. $language = language_load($form_state['values']['langcode']); @@ -112,6 +113,7 @@ function locale_translate_import_form_submit($form, &$form_state) { 'overwrite_options' => $form_state['values']['overwrite_options'], 'customized' => $form_state['values']['customized'] ? LOCALE_CUSTOMIZED : LOCALE_NOT_CUSTOMIZED, ); + $batch = locale_translate_batch_build(array($file->uri => $file), $options); batch_set($batch); }