updated core to 8.6.1 via composer

This commit is contained in:
2018-09-12 13:58:26 +02:00
parent a9a219f2ed
commit ea56b9fba3
4443 changed files with 112098 additions and 40708 deletions
+48 -30
View File
@@ -3,7 +3,7 @@
* Locale admin behavior.
*/
(function ($, Drupal) {
(function($, Drupal) {
/**
* Marks changes of translations.
*
@@ -16,16 +16,22 @@
*/
Drupal.behaviors.localeTranslateDirty = {
attach() {
const $form = $('#locale-translate-edit-form').once('localetranslatedirty');
const $form = $('#locale-translate-edit-form').once(
'localetranslatedirty',
);
if ($form.length) {
// Display a notice if any row changed.
$form.one('formUpdated.localeTranslateDirty', 'table', function () {
const $marker = $(Drupal.theme('localeTranslateChangedWarning')).hide();
$(this).addClass('changed').before($marker);
$form.one('formUpdated.localeTranslateDirty', 'table', function() {
const $marker = $(
Drupal.theme('localeTranslateChangedWarning'),
).hide();
$(this)
.addClass('changed')
.before($marker);
$marker.fadeIn('slow');
});
// Highlight changed row.
$form.on('formUpdated.localeTranslateDirty', 'tr', function () {
$form.on('formUpdated.localeTranslateDirty', 'tr', function() {
const $row = $(this);
const $rowToMark = $row.once('localemark');
const marker = Drupal.theme('localeTranslateChangedMarker');
@@ -40,7 +46,9 @@
},
detach(context, settings, trigger) {
if (trigger === 'unload') {
const $form = $('#locale-translate-edit-form').removeOnce('localetranslatedirty');
const $form = $('#locale-translate-edit-form').removeOnce(
'localetranslatedirty',
);
if ($form.length) {
$form.off('formUpdated.localeTranslateDirty');
}
@@ -58,12 +66,14 @@
*/
Drupal.behaviors.hideUpdateInformation = {
attach(context, settings) {
const $table = $('#locale-translation-status-form').once('expand-updates');
const $table = $('#locale-translation-status-form').once(
'expand-updates',
);
if ($table.length) {
const $tbodies = $table.find('tbody');
// Open/close the description details by toggling a tr class.
$tbodies.on('click keydown', '.description', function (e) {
$tbodies.on('click keydown', '.description', function(e) {
if (e.keyCode && (e.keyCode !== 13 && e.keyCode !== 32)) {
return;
}
@@ -86,26 +96,34 @@
},
};
$.extend(Drupal.theme, /** @lends Drupal.theme */{
$.extend(
Drupal.theme,
/** @lends Drupal.theme */ {
/**
* Creates markup for a changed translation marker.
*
* @return {string}
* Markup for the marker.
*/
localeTranslateChangedMarker() {
return `<abbr class="warning ajax-changed" title="${Drupal.t(
'Changed',
)}">*</abbr>`;
},
/**
* Creates markup for a changed translation marker.
*
* @return {string}
* Markup for the marker.
*/
localeTranslateChangedMarker() {
return `<abbr class="warning ajax-changed" title="${Drupal.t('Changed')}">*</abbr>`;
/**
* Creates markup for the translation changed warning.
*
* @return {string}
* Markup for the warning.
*/
localeTranslateChangedWarning() {
return `<div class="clearfix messages messages--warning">${Drupal.theme(
'localeTranslateChangedMarker',
)} ${Drupal.t(
'Changes made in this table will not be saved until the form is submitted.',
)}</div>`;
},
},
/**
* Creates markup for the translation changed warning.
*
* @return {string}
* Markup for the warning.
*/
localeTranslateChangedWarning() {
return `<div class="clearfix messages messages--warning">${Drupal.theme('localeTranslateChangedMarker')} ${Drupal.t('Changes made in this table will not be saved until the form is submitted.')}</div>`;
},
});
}(jQuery, Drupal));
);
})(jQuery, Drupal);
+6 -6
View File
@@ -104,22 +104,22 @@ function locale_translation_batch_status_finished($success, $results) {
else {
$message = \Drupal::translation()->formatPlural(count($results['failed_files']), 'One translation files could not be checked. See the log for details.', '@count translation files could not be checked. See the log for details.');
}
drupal_set_message($message, 'error');
\Drupal::messenger()->addError($message);
}
if (isset($results['files'])) {
drupal_set_message(\Drupal::translation()->formatPlural(
\Drupal::messenger()->addStatus(\Drupal::translation()->formatPlural(
count($results['files']),
'Checked available interface translation updates for one project.',
'Checked available interface translation updates for @count projects.'
));
}
if (!isset($results['failed_files']) && !isset($results['files'])) {
drupal_set_message(t('Nothing to check.'));
\Drupal::messenger()->addStatus(t('Nothing to check.'));
}
\Drupal::state()->set('locale.translation_last_checked', REQUEST_TIME);
}
else {
drupal_set_message(t('An error occurred trying to check available interface translation updates.'), 'error');
\Drupal::messenger()->addError(t('An error occurred trying to check available interface translation updates.'));
}
}
@@ -242,7 +242,7 @@ function locale_translation_http_check($uri) {
'allow_redirects' => [
'on_redirect' => function (RequestInterface $request, ResponseInterface $response, UriInterface $request_uri) use (&$actual_uri) {
$actual_uri = (string) $request_uri;
}
},
],
])->head($uri);
$result = [];
@@ -292,7 +292,7 @@ function locale_translation_http_check($uri) {
* File object if download was successful. FALSE on failure.
*/
function locale_translation_download_source($source_file, $directory = 'temporary://') {
if ($uri = system_retrieve_file($source_file->uri, $directory)) {
if ($uri = system_retrieve_file($source_file->uri, $directory, FALSE, FILE_EXISTS_REPLACE)) {
$file = clone($source_file);
$file->type = LOCALE_TRANSLATION_LOCAL;
$file->uri = $uri;
+15 -11
View File
@@ -3,7 +3,7 @@
* Locale behavior.
*/
(function ($, Drupal) {
(function($, Drupal) {
/**
* Select the language code of an imported file based on its filename.
*
@@ -19,16 +19,20 @@
const $form = $('#locale-translate-import-form').once('autodetect-lang');
if ($form.length) {
const $langcode = $form.find('.langcode-input');
$form.find('.file-import-input')
.on('change', function () {
// If the filename is fully the language code or the filename
// ends with a language code, pre-select that one.
const matches = $(this).val().match(/([^.][.]*)([\w-]+)\.po$/);
if (matches && $langcode.find(`option[value="${matches[2]}"]`).length) {
$langcode.val(matches[2]);
}
});
$form.find('.file-import-input').on('change', function() {
// If the filename is fully the language code or the filename
// ends with a language code, pre-select that one.
const matches = $(this)
.val()
.match(/([^.][.]*)([\w-]+)\.po$/);
if (
matches &&
$langcode.find(`option[value="${matches[2]}"]`).length
) {
$langcode.val(matches[2]);
}
});
}
},
};
}(jQuery, Drupal));
})(jQuery, Drupal);
+5 -5
View File
@@ -372,7 +372,7 @@ function locale_translate_batch_finished($success, array $results) {
else {
$message = \Drupal::translation()->formatPlural(count($results['failed_files']), 'One translation file could not be imported. See the log for details.', '@count translation files could not be imported. See the log for details.');
}
drupal_set_message($message, 'error');
\Drupal::messenger()->addError($message);
}
if (isset($results['files'])) {
$skipped_files = [];
@@ -389,7 +389,7 @@ function locale_translate_batch_finished($success, array $results) {
}
}
}
drupal_set_message(\Drupal::translation()->formatPlural(count($results['files']),
\Drupal::messenger()->addStatus(\Drupal::translation()->formatPlural(count($results['files']),
'One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.',
'@count translation files imported. %number translations were added, %update translations were updated and %delete translations were removed.',
['%number' => $additions, '%update' => $updates, '%delete' => $deletes]
@@ -403,7 +403,7 @@ function locale_translate_batch_finished($success, array $results) {
else {
$message = \Drupal::translation()->formatPlural($skips, 'One translation string was skipped because of disallowed or malformed HTML. See the log for details.', '@count translation strings were skipped because of disallowed or malformed HTML. See the log for details.');
}
drupal_set_message($message, 'warning');
\Drupal::messenger()->addWarning($message);
$logger->warning('@count disallowed HTML string(s) in files: @files.', ['@count' => $skips, '@files' => implode(',', $skipped_files)]);
}
}
@@ -630,11 +630,11 @@ function locale_config_batch_finished($success, array $results) {
if ($success) {
$configuration = isset($results['stats']['config']) ? $results['stats']['config'] : 0;
if ($configuration) {
drupal_set_message(t('The configuration was successfully updated. There are %number configuration objects updated.', ['%number' => $configuration]));
\Drupal::messenger()->addStatus(t('The configuration was successfully updated. There are %number configuration objects updated.', ['%number' => $configuration]));
\Drupal::logger('locale')->notice('The configuration was successfully updated. %number configuration objects updated.', ['%number' => $configuration]);
}
else {
drupal_set_message(t('No configuration objects have been updated.'));
\Drupal::messenger()->addStatus(t('No configuration objects have been updated.'));
\Drupal::logger('locale')->warning('No configuration objects have been updated.');
}
}
+1 -1
View File
@@ -161,7 +161,7 @@ function locale_translation_default_translation_server() {
// An additional check is required here. During the upgrade process
// \Drupal::config()->get() returns NULL. We use the defined value as
// fallback.
$pattern = $pattern ? $pattern : LOCALE_TRANSLATION_DEFAULT_SERVER_PATTERN;
$pattern = $pattern ? $pattern : LOCALE_TRANSLATION_DEFAULT_SERVER_PATTERN;
return [
'pattern' => $pattern,
+69 -66
View File
@@ -3,7 +3,7 @@
* Datepicker JavaScript for the Locale module.
*/
(function ($, Drupal, drupalSettings) {
(function($, Drupal, drupalSettings) {
/**
* Attaches language support to the jQuery UI datepicker component.
*
@@ -14,71 +14,74 @@
// This code accesses drupalSettings and localized strings via Drupal.t().
// So this code should run after these are initialized. By placing it in an
// attach behavior this is assured.
$.datepicker.regional['drupal-locale'] = $.extend({
closeText: Drupal.t('Done'),
prevText: Drupal.t('Prev'),
nextText: Drupal.t('Next'),
currentText: Drupal.t('Today'),
monthNames: [
Drupal.t('January', {}, { context: 'Long month name' }),
Drupal.t('February', {}, { context: 'Long month name' }),
Drupal.t('March', {}, { context: 'Long month name' }),
Drupal.t('April', {}, { context: 'Long month name' }),
Drupal.t('May', {}, { context: 'Long month name' }),
Drupal.t('June', {}, { context: 'Long month name' }),
Drupal.t('July', {}, { context: 'Long month name' }),
Drupal.t('August', {}, { context: 'Long month name' }),
Drupal.t('September', {}, { context: 'Long month name' }),
Drupal.t('October', {}, { context: 'Long month name' }),
Drupal.t('November', {}, { context: 'Long month name' }),
Drupal.t('December', {}, { context: 'Long month name' }),
],
monthNamesShort: [
Drupal.t('Jan'),
Drupal.t('Feb'),
Drupal.t('Mar'),
Drupal.t('Apr'),
Drupal.t('May'),
Drupal.t('Jun'),
Drupal.t('Jul'),
Drupal.t('Aug'),
Drupal.t('Sep'),
Drupal.t('Oct'),
Drupal.t('Nov'),
Drupal.t('Dec'),
],
dayNames: [
Drupal.t('Sunday'),
Drupal.t('Monday'),
Drupal.t('Tuesday'),
Drupal.t('Wednesday'),
Drupal.t('Thursday'),
Drupal.t('Friday'),
Drupal.t('Saturday'),
],
dayNamesShort: [
Drupal.t('Sun'),
Drupal.t('Mon'),
Drupal.t('Tue'),
Drupal.t('Wed'),
Drupal.t('Thu'),
Drupal.t('Fri'),
Drupal.t('Sat'),
],
dayNamesMin: [
Drupal.t('Su'),
Drupal.t('Mo'),
Drupal.t('Tu'),
Drupal.t('We'),
Drupal.t('Th'),
Drupal.t('Fr'),
Drupal.t('Sa'),
],
dateFormat: Drupal.t('mm/dd/yy'),
firstDay: 0,
isRTL: 0,
}, drupalSettings.jquery.ui.datepicker);
$.datepicker.regional['drupal-locale'] = $.extend(
{
closeText: Drupal.t('Done'),
prevText: Drupal.t('Prev'),
nextText: Drupal.t('Next'),
currentText: Drupal.t('Today'),
monthNames: [
Drupal.t('January', {}, { context: 'Long month name' }),
Drupal.t('February', {}, { context: 'Long month name' }),
Drupal.t('March', {}, { context: 'Long month name' }),
Drupal.t('April', {}, { context: 'Long month name' }),
Drupal.t('May', {}, { context: 'Long month name' }),
Drupal.t('June', {}, { context: 'Long month name' }),
Drupal.t('July', {}, { context: 'Long month name' }),
Drupal.t('August', {}, { context: 'Long month name' }),
Drupal.t('September', {}, { context: 'Long month name' }),
Drupal.t('October', {}, { context: 'Long month name' }),
Drupal.t('November', {}, { context: 'Long month name' }),
Drupal.t('December', {}, { context: 'Long month name' }),
],
monthNamesShort: [
Drupal.t('Jan'),
Drupal.t('Feb'),
Drupal.t('Mar'),
Drupal.t('Apr'),
Drupal.t('May'),
Drupal.t('Jun'),
Drupal.t('Jul'),
Drupal.t('Aug'),
Drupal.t('Sep'),
Drupal.t('Oct'),
Drupal.t('Nov'),
Drupal.t('Dec'),
],
dayNames: [
Drupal.t('Sunday'),
Drupal.t('Monday'),
Drupal.t('Tuesday'),
Drupal.t('Wednesday'),
Drupal.t('Thursday'),
Drupal.t('Friday'),
Drupal.t('Saturday'),
],
dayNamesShort: [
Drupal.t('Sun'),
Drupal.t('Mon'),
Drupal.t('Tue'),
Drupal.t('Wed'),
Drupal.t('Thu'),
Drupal.t('Fri'),
Drupal.t('Sat'),
],
dayNamesMin: [
Drupal.t('Su'),
Drupal.t('Mo'),
Drupal.t('Tu'),
Drupal.t('We'),
Drupal.t('Th'),
Drupal.t('Fr'),
Drupal.t('Sa'),
],
dateFormat: Drupal.t('mm/dd/yy'),
firstDay: 0,
isRTL: 0,
},
drupalSettings.jquery.ui.datepicker,
);
$.datepicker.setDefaults($.datepicker.regional['drupal-locale']);
},
};
}(jQuery, Drupal, drupalSettings));
})(jQuery, Drupal, drupalSettings);
+2 -2
View File
@@ -6,5 +6,5 @@ package: Multilingual
version: VERSION
core: 8.x
dependencies:
- language
- file
- drupal:language
- drupal:file
+13 -14
View File
@@ -261,13 +261,13 @@ function locale_translatable_language_list() {
*
* The index is computed from the formula of this language.
*
* @param $count
* @param int $count
* Number to return plural for.
* @param $langcode
* Optional language code to translate to a language other than
* what is used to display the page.
* @param string|null $langcode
* (optional) Language code to translate to a language other than what is used
* to display the page, or NULL for current language. Defaults to NULL.
*
* @return
* @return int
* The numeric index of the plural variant to use for this $langcode and
* $count combination or -1 if the language was not found or does not have a
* plural formula.
@@ -308,7 +308,6 @@ function locale_get_plural($count, $langcode = NULL) {
return $plural_indexes[$langcode][$count];
}
/**
* Implements hook_modules_installed().
*/
@@ -1113,9 +1112,6 @@ function _locale_strip_quotes($string) {
* @param string $filepath
* File name to parse.
*
* @return array
* Array of string objects to update indexed by context and source.
*
* @throws Exception
* If a non-local file is attempted to be parsed.
*/
@@ -1217,10 +1213,11 @@ function _locale_parse_js_file($filepath) {
* files are rebuilt (with locale_update_js_files()) the next time a
* request is served in that language.
*
* @param $langcode
* The language code for which the file needs to be refreshed.
* @param string|null $langcode
* (optional) The language code for which the file needs to be refreshed, or
* NULL to refresh all languages. Defaults to NULL.
*
* @return
* @return array
* New content of the 'system.javascript_parsed' variable.
*/
function _locale_invalidate_js($langcode = NULL) {
@@ -1245,8 +1242,9 @@ function _locale_invalidate_js($langcode = NULL) {
/**
* (Re-)Creates the JavaScript translation file for a language.
*
* @param $langcode
* The language, the translation file should be (re)created for.
* @param string|null $langcode
* (optional) The language that the translation file should be (re)created
* for, or NULL for the current language. Defaults to NULL.
*
* @return bool
* TRUE if translation file exists, FALSE otherwise.
@@ -1373,6 +1371,7 @@ function _locale_rebuild_js($langcode = NULL) {
return TRUE;
}
}
/**
* Form element callback: After build changes to the language update table.
*
+1 -1
View File
@@ -180,7 +180,7 @@ class ExportForm extends FormBase {
$form_state->setResponse($response);
}
else {
drupal_set_message($this->t('Nothing to export.'));
$this->messenger()->addStatus($this->t('Nothing to export.'));
}
}
+2 -1
View File
@@ -46,6 +46,7 @@ class ImportForm extends FormBase {
$container->get('language_manager')
);
}
/**
* Constructs a form for language import.
*
@@ -175,7 +176,7 @@ class ImportForm extends FormBase {
if (empty($language)) {
$language = ConfigurableLanguage::createFromLangcode($form_state->getValue('langcode'));
$language->save();
drupal_set_message($this->t('The language %language has been created.', ['%language' => $this->t($language->label())]));
$this->messenger()->addStatus($this->t('The language %language has been created.', ['%language' => $this->t($language->label())]));
}
$options = array_merge(_locale_translation_default_update_options(), [
'langcode' => $form_state->getValue('langcode'),
@@ -219,7 +219,7 @@ class TranslateEditForm extends TranslateFormBase {
}
}
drupal_set_message($this->t('The strings have been saved.'));
$this->messenger()->addStatus($this->t('The strings have been saved.'));
// Keep the user on the current pager page.
$page = $this->getRequest()->query->get('page');
@@ -43,7 +43,7 @@ class LocaleConfigManager {
/**
* The string storage for reading and writing translations.
*
* @var \Drupal\locale\StringStorageInterface;
* @var \Drupal\locale\StringStorageInterface
*/
protected $localeStorage;
+11 -1
View File
@@ -16,7 +16,7 @@ class PoDatabaseWriter implements PoWriterInterface {
* An associative array indicating what data should be overwritten, if any.
*
* Elements of the array:
* - override_options
* - overwrite_options
* - not_customized: boolean indicating that not customized strings should
* be overwritten.
* - customized: boolean indicating that customized strings should be
@@ -109,6 +109,16 @@ class PoDatabaseWriter implements PoWriterInterface {
/**
* Set the options for the current writer.
*
* @param array $options
* An associative array containing:
* - overwrite_options: An array of options. Each option contains:
* - not_customized: Boolean indicating that not customized strings should
* be overwritten.
* - customized: Boolean indicating that customized strings should be
* overwritten.
* - customized: The strings being imported should be saved as customized.
* One of LOCALE_CUSTOMIZED or LOCALE_NOT_CUSTOMIZED.
*/
public function setOptions(array $options) {
if (!isset($options['overwrite_options'])) {
+1
View File
@@ -10,6 +10,7 @@ namespace Drupal\locale;
* value, and is assumed to be in English language.
*/
class SourceString extends StringBase {
/**
* {@inheritdoc}
*/
@@ -4,4 +4,3 @@ description: 'Support module for testing early bootstrap getting of annotations
core: 8.x
package: Testing
version: VERSION
@@ -25,11 +25,6 @@ class LocaleConfigTranslationImportTest extends BrowserTestBase {
*/
protected function setUp() {
parent::setUp();
// @todo Re-enable the test and only skip it when the translation cannot be
// downloaded, or provide a translation as a fixture instead. See
// https://www.drupal.org/project/drupal/issues/2828143.
$this->markTestSkipped();
}
/**
@@ -51,6 +46,7 @@ class LocaleConfigTranslationImportTest extends BrowserTestBase {
// tests.
$this->config('locale.settings')
->set('translation.import_enabled', TRUE)
->set('translation.use_source', LOCALE_TRANSLATION_USE_SOURCE_LOCAL)
->save();
// Add translation permissions now that the locale module has been enabled.
@@ -96,6 +92,7 @@ class LocaleConfigTranslationImportTest extends BrowserTestBase {
// tests.
$this->config('locale.settings')
->set('translation.import_enabled', TRUE)
->set('translation.use_source', LOCALE_TRANSLATION_USE_SOURCE_LOCAL)
->save();
// Add predefined language.
@@ -134,7 +131,7 @@ class LocaleConfigTranslationImportTest extends BrowserTestBase {
$expected = [
'translatable_no_default' => 'This translation is preserved',
'translatable_default_with_translation' => 'This translation is preserved',
'translatable_default_with_no_translation' => 'This translation is preserved'
'translatable_default_with_no_translation' => 'This translation is preserved',
];
$this->assertEqual($expected, $override->get());
}
@@ -154,6 +151,7 @@ class LocaleConfigTranslationImportTest extends BrowserTestBase {
// tests.
$this->config('locale.settings')
->set('translation.import_enabled', TRUE)
->set('translation.use_source', LOCALE_TRANSLATION_USE_SOURCE_LOCAL)
->save();
// Add predefined language.
@@ -191,6 +189,7 @@ class LocaleConfigTranslationImportTest extends BrowserTestBase {
// tests.
$this->config('locale.settings')
->set('translation.import_enabled', TRUE)
->set('translation.use_source', LOCALE_TRANSLATION_USE_SOURCE_LOCAL)
->save();
// Add predefined language.
@@ -205,7 +204,7 @@ class LocaleConfigTranslationImportTest extends BrowserTestBase {
$expected = [
'translatable_default_with_translation' => 'Locale can translate Afrikaans',
'translatable_no_default' => 'This translation is preserved',
'translatable_default_with_no_translation' => 'This translation is preserved'
'translatable_default_with_no_translation' => 'This translation is preserved',
];
$this->assertEqual($expected, $override->get());
@@ -227,7 +226,7 @@ class LocaleConfigTranslationImportTest extends BrowserTestBase {
$override = \Drupal::languageManager()->getLanguageConfigOverride('af', 'locale_test_translate.settings');
$expected = [
'translatable_no_default' => 'This translation is preserved',
'translatable_default_with_no_translation' => 'This translation is preserved'
'translatable_default_with_no_translation' => 'This translation is preserved',
];
$this->assertEqual($expected, $override->get());
}
@@ -38,6 +38,7 @@ class LocaleConfigTranslationTest extends BrowserTestBase {
// tests.
$this->config('locale.settings')
->set('translation.import_enabled', TRUE)
->set('translation.use_source', LOCALE_TRANSLATION_USE_SOURCE_LOCAL)
->save();
// Add custom language.
@@ -45,7 +45,7 @@ class LocaleFileSystemFormTest extends BrowserTestBase {
// The setting should persist.
$translation_path = $this->publicFilesDirectory . '/translations_changed';
$fields = [
'translation_path' => $translation_path
'translation_path' => $translation_path,
];
$this->drupalPostForm(NULL, $fields, t('Save configuration'));
$this->drupalGet('admin/config/media/file-system');
@@ -52,6 +52,7 @@ class LocaleImportFunctionalTest extends BrowserTestBase {
// tests.
$this->config('locale.settings')
->set('translation.import_enabled', TRUE)
->set('translation.use_source', LOCALE_TRANSLATION_USE_SOURCE_LOCAL)
->save();
}
@@ -4,7 +4,7 @@ namespace Drupal\Tests\locale\Functional;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Tests\BrowserTestBase;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Render\FormattableMarkup;
/**
* Tests parsing js files for translatable strings.
@@ -92,10 +92,10 @@ class LocaleJavascriptTranslationTest extends BrowserTestBase {
$args = ['%source' => $str, '%context' => $context];
// Make sure that the string was found in the file.
$this->assertTrue(isset($source_strings[$str]), SafeMarkup::format('Found source string: %source', $args));
$this->assertTrue(isset($source_strings[$str]), new FormattableMarkup('Found source string: %source', $args));
// Make sure that the proper context was matched.
$message = $context ? SafeMarkup::format('Context for %source is %context', $args) : SafeMarkup::format('Context for %source is blank', $args);
$message = $context ? new FormattableMarkup('Context for %source is %context', $args) : new FormattableMarkup('Context for %source is blank', $args);
$this->assertTrue(isset($source_strings[$str]) && $source_strings[$str] === $context, $message);
}
@@ -0,0 +1,21 @@
<?php
namespace Drupal\Tests\locale\Functional;
/**
* Tests installing in a different language with a dev version string.
*
* @group locale
*/
class LocaleNonInteractiveDevInstallTest extends LocaleNonInteractiveInstallTest {
/**
* {@inheritdoc}
*/
protected function getVersionStringToTest() {
include_once $this->root . '/core/includes/install.core.inc';
$version = _install_get_version_info(\Drupal::VERSION);
return $version['major'] . '.' . $version['minor'] . '.x';
}
}
@@ -0,0 +1,57 @@
<?php
namespace Drupal\Tests\locale\Functional;
use Drupal\Tests\BrowserTestBase;
/**
* Tests installing in a different language with a non-dev version string.
*
* @group locale
*/
class LocaleNonInteractiveInstallTest extends BrowserTestBase {
/**
* Gets the version string to use in the translation file.
*
* @return string
* The version string to test, for example, '8.0.0' or '8.6.x'.
*/
protected function getVersionStringToTest() {
include_once $this->root . '/core/includes/install.core.inc';
$version = _install_get_version_info(\Drupal::VERSION);
return $version['major'] . '.0.0';
}
/**
* {@inheritdoc}
*/
protected function installParameters() {
$parameters = parent::installParameters();
// Install Drupal in German.
$parameters['parameters']['langcode'] = 'de';
// Create a po file so we don't attempt to download one from
// localize.drupal.org and to have a test translation that will not change.
\Drupal::service('file_system')->mkdir($this->publicFilesDirectory . '/translations', NULL, TRUE);
$contents = <<<ENDPO
msgid ""
msgstr ""
msgid "Enter the password that accompanies your username."
msgstr "Geben sie das Passwort für ihren Benutzernamen ein."
ENDPO;
$version = $this->getVersionStringToTest();
file_put_contents($this->publicFilesDirectory . "/translations/drupal-{$version}.de.po", $contents);
return $parameters;
}
/**
* Tests that the expected translated text appears on the login screen.
*/
public function testInstallerTranslations() {
$this->drupalGet('user/login');
$this->assertSession()->responseContains('Geben sie das Passwort für ihren Benutzernamen ein.');
}
}
@@ -0,0 +1,65 @@
<?php
namespace Drupal\Tests\locale\Functional;
use Drupal\Core\StreamWrapper\PublicStream;
use Drupal\language\Entity\ConfigurableLanguage;
use org\bovigo\vfs\vfsStream;
/**
* Tests locale translation download.
*
* @group locale
*/
class LocaleTranslationDownloadTest extends LocaleUpdateBase {
/**
* The virtual file stream for storing translations.
*
* @var \org\bovigo\vfs\vfsStreamDirectory
*/
protected $translationsStream;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$moduleHandler = $this->container->get('module_handler');
$moduleHandler->loadInclude('locale', 'inc', 'locale.batch');
ConfigurableLanguage::createFromLangcode('de')->save();
// Let the translations:// stream wrapper point to a virtual file system to
// make it independent from the test environment.
$this->translationsStream = vfsStream::setup('translations');
\Drupal::configFactory()->getEditable('locale.settings')
->set('translation.path', $this->translationsStream->url())
->save();
}
/**
* Tests translation download from remote sources.
*/
public function testUpdateImportSourceRemote() {
// Provide remote and 'previously' downloaded translation file.
$this->setTranslationFiles();
vfsStream::create([
'contrib_module_one-8.x-1.1.de._po' => '__old_content__',
], $this->translationsStream);
$url = \Drupal::service('url_generator')->generateFromRoute('<front>', [], ['absolute' => TRUE]);
$uri = $url . PublicStream::basePath() . '/remote/8.x/contrib_module_one/contrib_module_one-8.x-1.1.de._po';
$source_file = (object) [
'uri' => $uri,
];
$result = locale_translation_download_source($source_file, 'translations://');
$this->assertEquals('translations://contrib_module_one-8.x-1.1.de._po', $result->uri);
$this->assertFalse(file_exists('translations://contrib_module_one-8.x-1.1.de_0._po'));
$this->assertTrue(file_exists('translations://contrib_module_one-8.x-1.1.de._po'));
$this->assertNotContains('__old_content__', file_get_contents('translations://contrib_module_one-8.x-1.1.de._po'));
}
}
@@ -5,7 +5,7 @@ namespace Drupal\Tests\locale\Functional;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\Tests\BrowserTestBase;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Render\FormattableMarkup;
/**
* Adds a new locale and translates its name. Checks the validation of
@@ -259,13 +259,13 @@ class LocaleTranslationUiTest extends BrowserTestBase {
$locale_javascripts = \Drupal::state()->get('locale.translation.javascript') ?: [];
$js_file = 'public://' . $config->get('javascript.directory') . '/' . $langcode . '_' . $locale_javascripts[$langcode] . '.js';
$this->assertTrue($result = file_exists($js_file), SafeMarkup::format('JavaScript file created: %file', ['%file' => $result ? $js_file : 'not found']));
$this->assertTrue($result = file_exists($js_file), new FormattableMarkup('JavaScript file created: %file', ['%file' => $result ? $js_file : 'not found']));
// Test JavaScript translation rebuilding.
file_unmanaged_delete($js_file);
$this->assertTrue($result = !file_exists($js_file), SafeMarkup::format('JavaScript file deleted: %file', ['%file' => $result ? $js_file : 'found']));
$this->assertTrue($result = !file_exists($js_file), new FormattableMarkup('JavaScript file deleted: %file', ['%file' => $result ? $js_file : 'found']));
_locale_rebuild_js($langcode);
$this->assertTrue($result = file_exists($js_file), SafeMarkup::format('JavaScript file rebuilt: %file', ['%file' => $result ? $js_file : 'not found']));
$this->assertTrue($result = file_exists($js_file), new FormattableMarkup('JavaScript file rebuilt: %file', ['%file' => $result ? $js_file : 'not found']));
}
/**
@@ -5,7 +5,7 @@ namespace Drupal\Tests\locale\Functional;
use Drupal\Core\StreamWrapper\PublicStream;
use Drupal\file\Entity\File;
use Drupal\Tests\BrowserTestBase;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Render\FormattableMarkup;
/**
* Base class for testing updates to string translations.
@@ -63,6 +63,7 @@ abstract class LocaleUpdateBase extends BrowserTestBase {
// tests.
$this->config('locale.settings')
->set('translation.import_enabled', TRUE)
->set('translation.use_source', LOCALE_TRANSLATION_USE_SOURCE_LOCAL)
->save();
}
@@ -88,7 +89,7 @@ abstract class LocaleUpdateBase extends BrowserTestBase {
$edit = ['predefined_langcode' => $langcode];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
$this->container->get('language_manager')->reset();
$this->assertTrue(\Drupal::languageManager()->getLanguage($langcode), SafeMarkup::format('Language %langcode added.', ['%langcode' => $langcode]));
$this->assertTrue(\Drupal::languageManager()->getLanguage($langcode), new FormattableMarkup('Language %langcode added.', ['%langcode' => $langcode]));
}
/**
@@ -84,7 +84,7 @@ class LocaleUpdateCronTest extends LocaleUpdateBase {
// Check whether tasks are added to the queue.
$queue = \Drupal::queue('locale_translation', TRUE);
$this->assertEqual($queue->numberOfItems(), 3, 'Queue holds tasks for one project.');
$this->assertEqual($queue->numberOfItems(), 2, 'Queue holds tasks for one project.');
$item = $queue->claimItem();
$queue->releaseItem($item);
$this->assertEqual($item->data[1][0], 'contrib_module_two', 'Queue holds tasks for contrib module one.');
@@ -95,7 +95,7 @@ class LocaleUpdateCronTest extends LocaleUpdateBase {
// Check whether no more tasks are added to the queue.
$queue = \Drupal::queue('locale_translation', TRUE);
$this->assertEqual($queue->numberOfItems(), 3, 'Queue holds tasks for one project.');
$this->assertEqual($queue->numberOfItems(), 2, 'Queue holds tasks for one project.');
// Ensure last checked is updated to a greater time than the initial value.
sleep(1);
@@ -3,7 +3,6 @@
namespace Drupal\Tests\locale\Functional;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Component\Utility\SafeMarkup;
/**
* Tests for the user interface of project interface translations.
@@ -86,7 +85,7 @@ class LocaleUpdateInterfaceTest extends LocaleUpdateBase {
$release_details = new FormattableMarkup('@module (@version). @info', [
'@module' => 'Locale test translate',
'@version' => '1.3-dev',
'@info' => t('File not found at %local_path', ['%local_path' => 'core/modules/locale/tests/test.de.po'])
'@info' => t('File not found at %local_path', ['%local_path' => 'core/modules/locale/tests/test.de.po']),
]);
$this->assertRaw($release_details->__toString(), 'Release details');
@@ -112,7 +111,7 @@ class LocaleUpdateInterfaceTest extends LocaleUpdateBase {
// Check if translations are available for Drupal core.
$this->drupalGet('admin/reports/translations');
$this->assertText(t('Updates for: @project', ['@project' => t('Drupal core')]), 'Translations found');
$this->assertText(SafeMarkup::format('@module (@date)', ['@module' => t('Drupal core'), '@date' => format_date(REQUEST_TIME, 'html_date')]), 'Core translation update');
$this->assertText(new FormattableMarkup('@module (@date)', ['@module' => t('Drupal core'), '@date' => format_date(REQUEST_TIME, 'html_date')]), 'Core translation update');
$update_button = $this->xpath('//input[@type="submit"][@value="' . t('Update translations') . '"]');
$this->assertTrue($update_button, 'Update translations button');
}
@@ -37,7 +37,7 @@ class LocaleConfigSubscriberTest extends KernelTestBase {
/**
* The string storage used in this test.
*
* @var \Drupal\locale\StringStorageInterface;
* @var \Drupal\locale\StringStorageInterface
*/
protected $stringStorage;
@@ -187,7 +187,6 @@ class LocaleConfigSubscriberTest extends KernelTestBase {
$this->assertNoTranslation($config_name, $langcode);
}
/**
* Sets up a configuration string with a translation.
*
@@ -41,7 +41,6 @@ class LocaleTranslationProjectsTest extends KernelTestBase {
\Drupal::state()->set('locale.remove_core_project', TRUE);
}
/**
* Tests locale_translation_clear_cache_projects().
*/
@@ -21,7 +21,6 @@ class StringBaseTest extends UnitTestCase {
$string->save();
}
/**
* @covers ::delete
*/