Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663
This commit is contained in:
parent
eb34d130a8
commit
f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions
|
@ -94,8 +94,8 @@ class ImportForm extends FormBase {
|
|||
else {
|
||||
$default = key($existing_languages);
|
||||
$language_options = array(
|
||||
$this->t('Existing languages') => $existing_languages,
|
||||
$this->t('Languages not yet added') => $this->languageManager->getStandardLanguageListWithoutConfigured(),
|
||||
(string) $this->t('Existing languages') => $existing_languages,
|
||||
(string) $this->t('Languages not yet added') => $this->languageManager->getStandardLanguageListWithoutConfigured(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,14 +43,14 @@ class LocaleSettingsForm extends ConfigFormBase {
|
|||
'7' => $this->t('Weekly'),
|
||||
'30' => $this->t('Monthly'),
|
||||
),
|
||||
'#description' => $this->t('Select how frequently you want to check for new interface translations for your currently installed modules and themes. <a href="@url">Check updates now</a>.', array('@url' => $this->url('locale.check_translation'))),
|
||||
'#description' => $this->t('Select how frequently you want to check for new interface translations for your currently installed modules and themes. <a href=":url">Check updates now</a>.', array(':url' => $this->url('locale.check_translation'))),
|
||||
);
|
||||
|
||||
if ($directory = $config->get('translation.path')) {
|
||||
$description = $this->t('Translation files are stored locally in the %path directory. You can change this directory on the <a href="@url">File system</a> configuration page.', array('%path' => $directory, '@url' => $this->url('system.file_system_settings')));
|
||||
$description = $this->t('Translation files are stored locally in the %path directory. You can change this directory on the <a href=":url">File system</a> configuration page.', array('%path' => $directory, ':url' => $this->url('system.file_system_settings')));
|
||||
}
|
||||
else {
|
||||
$description = $this->t('Translation files will not be stored locally. Change the Interface translation directory on the <a href="@url">File system configuration</a> page.', array('@url' => $this->url('system.file_system_settings')));
|
||||
$description = $this->t('Translation files will not be stored locally. Change the Interface translation directory on the <a href=":url">File system configuration</a> page.', array(':url' => $this->url('system.file_system_settings')));
|
||||
}
|
||||
$form['#translation_directory'] = $directory;
|
||||
$form['use_source'] = array(
|
||||
|
@ -95,7 +95,7 @@ class LocaleSettingsForm extends ConfigFormBase {
|
|||
parent::validateForm($form, $form_state);
|
||||
|
||||
if (empty($form['#translation_directory']) && $form_state->getValue('use_source') == LOCALE_TRANSLATION_USE_SOURCE_LOCAL) {
|
||||
$form_state->setErrorByName('use_source', $this->t('You have selected local translation source, but no <a href="@url">Interface translation directory</a> was configured.', array('@url' => $this->url('system.file_system_settings'))));
|
||||
$form_state->setErrorByName('use_source', $this->t('You have selected local translation source, but no <a href=":url">Interface translation directory</a> was configured.', array(':url' => $this->url('system.file_system_settings'))));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -90,7 +90,6 @@ class TranslationStatusForm extends FormBase {
|
|||
}
|
||||
$options[$langcode] = array(
|
||||
'title' => array(
|
||||
'class' => array('label'),
|
||||
'data' => array(
|
||||
'#title' => $title,
|
||||
'#plain_text' => $title,
|
||||
|
@ -133,16 +132,16 @@ class TranslationStatusForm extends FormBase {
|
|||
);
|
||||
|
||||
if (!$languages) {
|
||||
$empty = $this->t('No translatable languages available. <a href="@add_language">Add a language</a> first.', array(
|
||||
'@add_language' => $this->url('entity.configurable_language.collection'),
|
||||
$empty = $this->t('No translatable languages available. <a href=":add_language">Add a language</a> first.', array(
|
||||
':add_language' => $this->url('entity.configurable_language.collection'),
|
||||
));
|
||||
}
|
||||
elseif ($status) {
|
||||
$empty = $this->t('All translations up to date.');
|
||||
}
|
||||
else {
|
||||
$empty = $this->t('No translation status available. <a href="@check">Check manually</a>.', array(
|
||||
'@check' => $this->url('locale.check_translation'),
|
||||
$empty = $this->t('No translation status available. <a href=":check">Check manually</a>.', array(
|
||||
':check' => $this->url('locale.check_translation'),
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -233,9 +232,6 @@ class TranslationStatusForm extends FormBase {
|
|||
* This method will produce debug information including the respective path(s)
|
||||
* based on this setting.
|
||||
*
|
||||
* Translations for development versions are never fetched, so the debug info
|
||||
* for that is a fixed message.
|
||||
*
|
||||
* @param array $project_info
|
||||
* An array which is the project information of the source.
|
||||
*
|
||||
|
@ -246,9 +242,6 @@ class TranslationStatusForm extends FormBase {
|
|||
$remote_path = isset($project_info->files['remote']->uri) ? $project_info->files['remote']->uri : FALSE;
|
||||
$local_path = isset($project_info->files['local']->uri) ? $project_info->files['local']->uri : FALSE;
|
||||
|
||||
if (strpos($project_info->version, 'dev') !== FALSE) {
|
||||
return $this->t('No translation files are provided for development releases.');
|
||||
}
|
||||
if (locale_translation_use_remote_source() && $remote_path && $local_path) {
|
||||
return $this->t('File not found at %remote_path nor at %local_path', array(
|
||||
'%remote_path' => $remote_path,
|
||||
|
|
|
@ -12,7 +12,7 @@ use Drupal\Core\Config\ConfigFactoryInterface;
|
|||
use Drupal\Core\Config\InstallStorage;
|
||||
use Drupal\Core\Config\StorageInterface;
|
||||
use Drupal\Core\Config\TypedConfigManagerInterface;
|
||||
use Drupal\Core\StringTranslation\TranslationWrapper;
|
||||
use Drupal\Core\StringTranslation\TranslatableMarkup;
|
||||
use Drupal\Core\TypedData\TraversableTypedDataInterface;
|
||||
use Drupal\Core\TypedData\TypedDataInterface;
|
||||
use Drupal\language\ConfigurableLanguageManagerInterface;
|
||||
|
@ -122,13 +122,14 @@ class LocaleConfigManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets array of translation wrappers for translatable configuration.
|
||||
* Gets array of translated strings for Locale translatable configuration.
|
||||
*
|
||||
* @param string $name
|
||||
* Configuration object name.
|
||||
*
|
||||
* @return array
|
||||
* Array of translatable elements of the default configuration in $name.
|
||||
* Array of Locale translatable elements of the default configuration in
|
||||
* $name.
|
||||
*/
|
||||
public function getTranslatableDefaultConfig($name) {
|
||||
if ($this->isSupported($name)) {
|
||||
|
@ -150,11 +151,11 @@ class LocaleConfigManager {
|
|||
* @param \Drupal\Core\TypedData\TypedDataInterface $element
|
||||
* Typed configuration element.
|
||||
*
|
||||
* @return array|\Drupal\Core\StringTranslation\TranslationWrapper
|
||||
* @return array|\Drupal\Core\StringTranslation\TranslatableMarkup
|
||||
* A nested array matching the exact structure under $element with only the
|
||||
* elements that are translatable wrapped into a TranslationWrapper. If the
|
||||
* elements that are translatable wrapped into a TranslatableMarkup. If the
|
||||
* provided $element is not traversable, the return value is a single
|
||||
* TranslationWrapper.
|
||||
* TranslatableMarkup.
|
||||
*/
|
||||
protected function getTranslatableData(TypedDataInterface $element) {
|
||||
$translatable = array();
|
||||
|
@ -167,13 +168,16 @@ class LocaleConfigManager {
|
|||
}
|
||||
}
|
||||
else {
|
||||
// Something is only translatable by Locale if there is a string in the
|
||||
// first place.
|
||||
$value = $element->getValue();
|
||||
$definition = $element->getDataDefinition();
|
||||
if (!empty($definition['translatable'])) {
|
||||
if (!empty($definition['translatable']) && $value !== '' && $value !== NULL) {
|
||||
$options = array();
|
||||
if (isset($definition['translation context'])) {
|
||||
$options['context'] = $definition['translation context'];
|
||||
}
|
||||
return new TranslationWrapper($element->getValue(), array(), $options);
|
||||
return new TranslatableMarkup($value, array(), $options);
|
||||
}
|
||||
}
|
||||
return $translatable;
|
||||
|
@ -191,10 +195,10 @@ class LocaleConfigManager {
|
|||
* The configuration name.
|
||||
* @param array $active
|
||||
* The active configuration data.
|
||||
* @param array|\Drupal\Core\StringTranslation\TranslationWrapper[] $translatable
|
||||
* @param array|\Drupal\Core\StringTranslation\TranslatableMarkup[] $translatable
|
||||
* The translatable array structure. A nested array matching the exact
|
||||
* structure under of the default configuration for $name with only the
|
||||
* elements that are translatable wrapped into a TranslationWrapper.
|
||||
* elements that are translatable wrapped into a TranslatableMarkup.
|
||||
* @see self::getTranslatableData().
|
||||
* @param string $langcode
|
||||
* The language code to process the array with.
|
||||
|
@ -559,33 +563,27 @@ class LocaleConfigManager {
|
|||
|
||||
foreach ($langcodes as $langcode) {
|
||||
$processed = $this->processTranslatableData($name, $active, $translatable, $langcode);
|
||||
// If the language code is not the same as the active storage
|
||||
// language, we should update the configuration override.
|
||||
if ($langcode != $active_langcode) {
|
||||
// If the language code is not the same as the active storage
|
||||
// language, we should update a configuration override.
|
||||
$override = $this->languageManager->getLanguageConfigOverride($langcode, $name);
|
||||
// Filter out locale managed configuration keys so that translations
|
||||
// removed from Locale will be reflected in the config override.
|
||||
$data = $this->filterOverride($override->get(), $translatable);
|
||||
if (!empty($processed)) {
|
||||
// Update translation data in configuration override.
|
||||
$this->saveTranslationOverride($name, $langcode, $processed);
|
||||
// Merge in the Locale managed translations with existing data.
|
||||
$data = NestedArray::mergeDeepArray(array($data, $processed), TRUE);
|
||||
}
|
||||
if (empty($data) && !$override->isNew()) {
|
||||
// The configuration override contains Locale overrides that no
|
||||
// longer exist.
|
||||
$this->deleteTranslationOverride($name, $langcode);
|
||||
$count++;
|
||||
}
|
||||
else {
|
||||
$override = $this->languageManager->getLanguageConfigOverride($langcode, $name);
|
||||
if (!$override->isNew()) {
|
||||
$data = $this->filterOverride($override->get(), $translatable);
|
||||
if (empty($data)) {
|
||||
// Delete language override if there is no data left at all.
|
||||
// This means all prior translations in the override were locale
|
||||
// managed.
|
||||
$this->deleteTranslationOverride($name, $langcode);
|
||||
$count++;
|
||||
}
|
||||
else {
|
||||
// If there were translatable elements besides locale managed
|
||||
// items, save with only those, and remove the ones managed
|
||||
// by locale only.
|
||||
$this->saveTranslationOverride($name, $langcode, $data);
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
elseif (!empty($data)) {
|
||||
// Update translation data in configuration override.
|
||||
$this->saveTranslationOverride($name, $langcode, $data);
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
elseif (locale_is_translatable($langcode)) {
|
||||
|
|
|
@ -133,7 +133,7 @@ class LocaleConfigSubscriber implements EventSubscriberInterface {
|
|||
* The configuration name.
|
||||
* @param array $config
|
||||
* The active configuration data or override data.
|
||||
* @param array|\Drupal\Core\StringTranslation\TranslationWrapper[] $translatable
|
||||
* @param array|\Drupal\Core\StringTranslation\TranslatableMarkup[] $translatable
|
||||
* The translatable array structure.
|
||||
* @see \Drupal\locale\LocaleConfigManager::getTranslatableData()
|
||||
* @param string $langcode
|
||||
|
@ -169,9 +169,9 @@ class LocaleConfigSubscriber implements EventSubscriberInterface {
|
|||
*
|
||||
* @param string $name
|
||||
* The configuration name.
|
||||
* @param array|\Drupal\Core\StringTranslation\TranslationWrapper $translatable
|
||||
* Either a possibly nested array with TranslationWrapper objects at the
|
||||
* leaf items or a TranslationWrapper object directly.
|
||||
* @param array|\Drupal\Core\StringTranslation\TranslatableMarkup $translatable
|
||||
* Either a possibly nested array with TranslatableMarkup objects at the
|
||||
* leaf items or a TranslatableMarkup object directly.
|
||||
* @param array|string $reference_config
|
||||
* Either a possibly nested array with strings at the leaf items or a string
|
||||
* directly. Only those $translatable items that are also present in
|
||||
|
|
116
core/modules/locale/src/PluralFormula.php
Normal file
116
core/modules/locale/src/PluralFormula.php
Normal file
|
@ -0,0 +1,116 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\locale\PluralFormula.
|
||||
*/
|
||||
|
||||
namespace Drupal\locale;
|
||||
|
||||
use Drupal\Core\Language\LanguageManagerInterface;
|
||||
use Drupal\Core\State\StateInterface;
|
||||
|
||||
/**
|
||||
* Manages the storage of plural formula per language in state.
|
||||
*
|
||||
* @see \Drupal\locale\PoDatabaseWriter::setHeader()
|
||||
*/
|
||||
class PluralFormula implements PluralFormulaInterface {
|
||||
|
||||
/**
|
||||
* @var \Drupal\Core\Language\LanguageManagerInterface
|
||||
*/
|
||||
protected $languageManager;
|
||||
|
||||
/**
|
||||
* @var \Drupal\Core\State\StateInterface
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* The plural formula and count keyed by langcode.
|
||||
*
|
||||
* For example the structure looks like this:
|
||||
* @code
|
||||
* [
|
||||
* 'de' => [
|
||||
* 'plurals' => 2,
|
||||
* 'formula' => [
|
||||
* // @todo
|
||||
* ]
|
||||
* ],
|
||||
* ]
|
||||
* @endcode
|
||||
* @var []
|
||||
*/
|
||||
protected $formulae;
|
||||
|
||||
/**
|
||||
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
|
||||
* @param \Drupal\Core\State\StateInterface $state
|
||||
*/
|
||||
public function __construct(LanguageManagerInterface $language_manager, StateInterface $state) {
|
||||
$this->languageManager = $language_manager;
|
||||
$this->state = $state;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setPluralFormula($langcode, $plural_count, array $formula) {
|
||||
// Ensure that the formulae are loaded.
|
||||
$this->loadFormulae();
|
||||
|
||||
$this->formulae[$langcode] = [
|
||||
'plurals' => $plural_count,
|
||||
'formula' => $formula,
|
||||
];
|
||||
$this->state->set('locale.translation.formulae', $this->formulae);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getNumberOfPlurals($langcode = NULL) {
|
||||
// Ensure that the formulae are loaded.
|
||||
$this->loadFormulae();
|
||||
|
||||
// Set the langcode to use.
|
||||
$langcode = $langcode ?: $this->languageManager->getCurrentLanguage()->getId();
|
||||
|
||||
// We assume 2 plurals if there is no explicit information yet.
|
||||
if (!isset($this->formulae[$langcode]['plurals'])) {
|
||||
return 2;
|
||||
}
|
||||
return $this->formulae[$langcode]['plurals'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFormula($langcode) {
|
||||
$this->loadFormulae();
|
||||
return isset($this->formulae[$langcode]['formula']) ? $this->formulae[$langcode]['formula'] : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the formulae and stores them on the PluralFormula object if not set.
|
||||
*
|
||||
* @return []
|
||||
*/
|
||||
protected function loadFormulae() {
|
||||
if (!isset($this->formulae)) {
|
||||
$this->formulae = $this->state->get('locale.translation.formulae', []);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function reset() {
|
||||
$this->formulae = NULL;
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
59
core/modules/locale/src/PluralFormulaInterface.php
Normal file
59
core/modules/locale/src/PluralFormulaInterface.php
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\locale\PluralFormulaInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\locale;
|
||||
|
||||
/**
|
||||
* An interface for a service providing plural formulae.
|
||||
*/
|
||||
interface PluralFormulaInterface {
|
||||
|
||||
/**
|
||||
* @param string $langcode
|
||||
* The language code to get the formula for.
|
||||
* @param int $plural_count
|
||||
* The number of plural forms.
|
||||
* @param array $formula
|
||||
* An array of formulae.
|
||||
*
|
||||
* @return self
|
||||
* The PluralFormula object.
|
||||
*/
|
||||
public function setPluralFormula($langcode, $plural_count, array $formula);
|
||||
|
||||
/**
|
||||
* Returns the number of plurals supported by a given language.
|
||||
*
|
||||
* @param null|string $langcode
|
||||
* (optional) The language code. If not provided, the current language
|
||||
* will be used.
|
||||
*
|
||||
* @return int
|
||||
* Number of plural variants supported by the given language.
|
||||
*/
|
||||
public function getNumberOfPlurals($langcode = NULL);
|
||||
|
||||
/**
|
||||
* Gets the plural formula for a langcode.
|
||||
*
|
||||
* @param string $langcode
|
||||
* The language code to get the formula for.
|
||||
*
|
||||
* @return array
|
||||
* An array of formulae.
|
||||
*/
|
||||
public function getFormula($langcode);
|
||||
|
||||
/**
|
||||
* Resets the static formulae cache.
|
||||
*
|
||||
* @return self
|
||||
* The PluralFormula object.
|
||||
*/
|
||||
public function reset();
|
||||
|
||||
}
|
|
@ -175,11 +175,7 @@ class PoDatabaseWriter implements PoWriterInterface {
|
|||
$plural = $header->getPluralForms();
|
||||
if (isset($plural) && $p = $header->parsePluralForms($plural)) {
|
||||
list($nplurals, $formula) = $p;
|
||||
$locale_plurals[$langcode] = array(
|
||||
'plurals' => $nplurals,
|
||||
'formula' => $formula,
|
||||
);
|
||||
\Drupal::state()->set('locale.translation.plurals', $locale_plurals);
|
||||
\Drupal::service('locale.plural.formula')->setPluralFormula($langcode, $nplurals, $formula);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
namespace Drupal\locale\Tests;
|
||||
|
||||
use Drupal\locale\Locale;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\Core\Url;
|
||||
|
@ -23,26 +24,14 @@ class LocaleConfigTranslationImportTest extends WebTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('language', 'update', 'locale_test_translate');
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$admin_user = $this->drupalCreateUser(array('administer modules', 'administer site configuration', 'administer languages', 'access administration pages', 'administer permissions'));
|
||||
$this->drupalLogin($admin_user);
|
||||
|
||||
// Update module should not go out to d.o to check for updates. We override
|
||||
// the url to an invalid update source. No update data will be found.
|
||||
$this->config('update.settings')->set('fetch.url', (string) Url::fromRoute('<front>')->setAbsolute()->toString())->save();
|
||||
}
|
||||
public static $modules = array('language', 'locale_test_translate');
|
||||
|
||||
/**
|
||||
* Test update changes configuration translations if enabled after language.
|
||||
*/
|
||||
public function testConfigTranslationImport() {
|
||||
$admin_user = $this->drupalCreateUser(array('administer modules', 'administer site configuration', 'administer languages', 'access administration pages', 'administer permissions'));
|
||||
$this->drupalLogin($admin_user);
|
||||
|
||||
// Add a language. The Afrikaans translation file of locale_test_translate
|
||||
// (test.af.po) has been prepared with a configuration translation.
|
||||
|
@ -81,4 +70,156 @@ class LocaleConfigTranslationImportTest extends WebTestBase {
|
|||
$this->assertEqual($override->get('message'), 'Ons is tans besig met onderhoud op @site. Wees asseblief geduldig, ons sal binnekort weer terug wees.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test update changes configuration translations if enabled after language.
|
||||
*/
|
||||
public function testConfigTranslationModuleInstall() {
|
||||
|
||||
// Enable locale, block and config_translation modules.
|
||||
$this->container->get('module_installer')->install(['block', 'config_translation']);
|
||||
$this->resetAll();
|
||||
|
||||
$admin_user = $this->drupalCreateUser(array('administer modules', 'administer site configuration', 'administer languages', 'access administration pages', 'administer permissions', 'translate configuration'));
|
||||
$this->drupalLogin($admin_user);
|
||||
|
||||
// Enable import of translations. By default this is disabled for automated
|
||||
// tests.
|
||||
$this->config('locale.settings')
|
||||
->set('translation.import_enabled', TRUE)
|
||||
->save();
|
||||
|
||||
// Add predefined language.
|
||||
$this->drupalPostForm('admin/config/regional/language/add', ['predefined_langcode' => 'af'], t('Add language'));
|
||||
|
||||
// Add the system branding block to the page.
|
||||
$this->drupalPlaceBlock('system_branding_block', array('region' => 'header', 'id' => 'site-branding'));
|
||||
$this->drupalPostForm('admin/config/system/site-information', ['site_slogan' => 'Test site slogan'], 'Save configuration');
|
||||
$this->drupalPostForm('admin/config/system/site-information/translate/af/edit', ['translation[config_names][system.site][slogan]' => 'Test site slogan in Afrikaans'], 'Save translation');
|
||||
|
||||
// Get the front page and ensure that the translated configuration appears.
|
||||
$this->drupalGet('af');
|
||||
$this->assertText('Test site slogan in Afrikaans');
|
||||
|
||||
$override = \Drupal::languageManager()->getLanguageConfigOverride('af', 'locale_test_translate.settings');
|
||||
$this->assertEqual('Locale can translate Afrikaans', $override->get('translatable_default_with_translation'));
|
||||
|
||||
// Update test configuration.
|
||||
$override
|
||||
->set('translatable_no_default', 'This translation is preserved')
|
||||
->set('translatable_default_with_translation', 'This translation is preserved')
|
||||
->set('translatable_default_with_no_translation', 'This translation is preserved')
|
||||
->save();
|
||||
|
||||
// Install any module.
|
||||
$this->drupalPostForm('admin/modules', ['modules[Core][dblog][enable]' => 'dblog'], t('Install'));
|
||||
$this->assertText('Module Database Logging has been enabled.');
|
||||
|
||||
// Get the front page and ensure that the translated configuration still
|
||||
// appears.
|
||||
$this->drupalGet('af');
|
||||
$this->assertText('Test site slogan in Afrikaans');
|
||||
|
||||
$this->rebuildContainer();
|
||||
$override = \Drupal::languageManager()->getLanguageConfigOverride('af', 'locale_test_translate.settings');
|
||||
$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'
|
||||
];
|
||||
$this->assertEqual($expected, $override->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test removing a string from Locale deletes configuration translations.
|
||||
*/
|
||||
function testLocaleRemovalAndConfigOverrideDelete() {
|
||||
// Enable the locale module.
|
||||
$this->container->get('module_installer')->install(['locale']);
|
||||
$this->resetAll();
|
||||
|
||||
$admin_user = $this->drupalCreateUser(array('administer modules', 'administer site configuration', 'administer languages', 'access administration pages', 'administer permissions', 'translate interface'));
|
||||
$this->drupalLogin($admin_user);
|
||||
|
||||
// Enable import of translations. By default this is disabled for automated
|
||||
// tests.
|
||||
$this->config('locale.settings')
|
||||
->set('translation.import_enabled', TRUE)
|
||||
->save();
|
||||
|
||||
// Add predefined language.
|
||||
$this->drupalPostForm('admin/config/regional/language/add', ['predefined_langcode' => 'af'], t('Add language'));
|
||||
|
||||
$override = \Drupal::languageManager()->getLanguageConfigOverride('af', 'locale_test_translate.settings');
|
||||
$this->assertEqual(['translatable_default_with_translation' => 'Locale can translate Afrikaans'], $override->get());
|
||||
|
||||
// Remove the string from translation to simulate a Locale removal. Note
|
||||
// that is no current way of doing this in the UI.
|
||||
$locale_storage = \Drupal::service('locale.storage');
|
||||
$string = $locale_storage->findString(array('source' => 'Locale can translate'));
|
||||
\Drupal::service('locale.storage')->delete($string);
|
||||
// Force a rebuild of config translations.
|
||||
$count = Locale::config()->updateConfigTranslations(['locale_test_translate.settings'], ['af']);
|
||||
$this->assertEqual($count, 1, 'Correct count of updated translations');
|
||||
|
||||
$override = \Drupal::languageManager()->getLanguageConfigOverride('af', 'locale_test_translate.settings');
|
||||
$this->assertEqual([], $override->get());
|
||||
$this->assertTrue($override->isNew(), 'The configuration override was deleted when the Locale string was deleted.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test removing a string from Locale changes configuration translations.
|
||||
*/
|
||||
function testLocaleRemovalAndConfigOverridePreserve() {
|
||||
// Enable the locale module.
|
||||
$this->container->get('module_installer')->install(['locale']);
|
||||
$this->resetAll();
|
||||
|
||||
$admin_user = $this->drupalCreateUser(array('administer modules', 'administer site configuration', 'administer languages', 'access administration pages', 'administer permissions', 'translate interface'));
|
||||
$this->drupalLogin($admin_user);
|
||||
|
||||
// Enable import of translations. By default this is disabled for automated
|
||||
// tests.
|
||||
$this->config('locale.settings')
|
||||
->set('translation.import_enabled', TRUE)
|
||||
->save();
|
||||
|
||||
// Add predefined language.
|
||||
$this->drupalPostForm('admin/config/regional/language/add', ['predefined_langcode' => 'af'], t('Add language'));
|
||||
|
||||
$override = \Drupal::languageManager()->getLanguageConfigOverride('af', 'locale_test_translate.settings');
|
||||
// Update test configuration.
|
||||
$override
|
||||
->set('translatable_no_default', 'This translation is preserved')
|
||||
->set('translatable_default_with_no_translation', 'This translation is preserved')
|
||||
->save();
|
||||
$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'
|
||||
];
|
||||
$this->assertEqual($expected, $override->get());
|
||||
|
||||
// Set the translated string to empty.
|
||||
$search = array(
|
||||
'string' => 'Locale can translate',
|
||||
'langcode' => 'af',
|
||||
'translation' => 'all',
|
||||
);
|
||||
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
|
||||
$textareas = $this->xpath('//textarea');
|
||||
$textarea = current($textareas);
|
||||
$lid = (string) $textarea[0]['name'];
|
||||
$edit = array(
|
||||
$lid => '',
|
||||
);
|
||||
$this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations'));
|
||||
|
||||
$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'
|
||||
];
|
||||
$this->assertEqual($expected, $override->get());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -76,8 +76,8 @@ class LocaleImportFunctionalTest extends WebTestBase {
|
|||
$this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', array('%number' => 8, '%update' => 0, '%delete' => 0)), 'The translation file was successfully imported.');
|
||||
|
||||
// This import should have saved plural forms to have 2 variants.
|
||||
$locale_plurals = \Drupal::state()->get('locale.translation.plurals') ?: array();
|
||||
$this->assert($locale_plurals['fr']['plurals'] == 2, 'Plural number initialized.');
|
||||
$locale_plurals = \Drupal::service('locale.plural.formula')->getNumberOfPlurals('fr');
|
||||
$this->assertEqual(2, $locale_plurals, 'Plural number initialized.');
|
||||
|
||||
// Ensure we were redirected correctly.
|
||||
$this->assertUrl(\Drupal::url('locale.translate_page', [], ['absolute' => TRUE]), [], 'Correct page redirection.');
|
||||
|
@ -90,7 +90,7 @@ class LocaleImportFunctionalTest extends WebTestBase {
|
|||
// The import should have created 1 string and rejected 2.
|
||||
$this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', array('%number' => 1, '%update' => 0, '%delete' => 0)), 'The translation file was successfully imported.');
|
||||
|
||||
$skip_message = \Drupal::translation()->formatPlural(2, 'One translation string was skipped because of disallowed or malformed HTML. <a href="@url">See the log</a> for details.', '@count translation strings were skipped because of disallowed or malformed HTML. See the log for details.', array('@url' => \Drupal::url('dblog.overview')));
|
||||
$skip_message = \Drupal::translation()->formatPlural(2, 'One translation string was skipped because of disallowed or malformed HTML. <a href=":url">See the log</a> for details.', '@count translation strings were skipped because of disallowed or malformed HTML. See the log for details.', array(':url' => \Drupal::url('dblog.overview')));
|
||||
$this->assertRaw($skip_message, 'Unsafe strings were skipped.');
|
||||
|
||||
// Repeat the process with a user that can access site reports, and this
|
||||
|
@ -102,7 +102,7 @@ class LocaleImportFunctionalTest extends WebTestBase {
|
|||
'langcode' => 'fr',
|
||||
));
|
||||
|
||||
$skip_message = \Drupal::translation()->formatPlural(2, 'One translation string was skipped because of disallowed or malformed HTML. <a href="@url">See the log</a> for details.', '@count translation strings were skipped because of disallowed or malformed HTML. <a href="@url">See the log</a> for details.', array('@url' => \Drupal::url('dblog.overview')));
|
||||
$skip_message = \Drupal::translation()->formatPlural(2, 'One translation string was skipped because of disallowed or malformed HTML. <a href=":url">See the log</a> for details.', '@count translation strings were skipped because of disallowed or malformed HTML. <a href=":url">See the log</a> for details.', array(':url' => \Drupal::url('dblog.overview')));
|
||||
$this->assertRaw($skip_message, 'Unsafe strings were skipped.');
|
||||
|
||||
// Check empty files import with a user that cannot access site reports..
|
||||
|
@ -122,7 +122,7 @@ class LocaleImportFunctionalTest extends WebTestBase {
|
|||
'langcode' => 'fr',
|
||||
));
|
||||
// The import should have created 0 string and rejected 0.
|
||||
$this->assertRaw(t('One translation file could not be imported. <a href="@url">See the log</a> for details.', array('@url' => \Drupal::url('dblog.overview'))), 'The empty translation file import reported no translations imported.');
|
||||
$this->assertRaw(t('One translation file could not be imported. <a href=":url">See the log</a> for details.', array(':url' => \Drupal::url('dblog.overview'))), 'The empty translation file import reported no translations imported.');
|
||||
|
||||
// Try importing a .po file which doesn't exist.
|
||||
$name = $this->randomMachineName(16);
|
||||
|
@ -151,8 +151,8 @@ class LocaleImportFunctionalTest extends WebTestBase {
|
|||
$this->assertText(t('No strings available.'), 'String not overwritten by imported string.');
|
||||
|
||||
// This import should not have changed number of plural forms.
|
||||
$locale_plurals = \Drupal::state()->get('locale.translation.plurals') ?: array();
|
||||
$this->assert($locale_plurals['fr']['plurals'] == 2, 'Plural numbers untouched.');
|
||||
$locale_plurals = \Drupal::service('locale.plural.formula')->getNumberOfPlurals('fr');
|
||||
$this->assertEqual(2, $locale_plurals, 'Plural numbers untouched.');
|
||||
|
||||
// Try importing a .po file with overriding strings, and ensure existing
|
||||
// strings are overwritten.
|
||||
|
@ -172,8 +172,8 @@ class LocaleImportFunctionalTest extends WebTestBase {
|
|||
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
|
||||
$this->assertNoText(t('No strings available.'), 'String overwritten by imported string.');
|
||||
// This import should have changed number of plural forms.
|
||||
$locale_plurals = \Drupal::state()->get('locale.translation.plurals') ?: array();
|
||||
$this->assert($locale_plurals['fr']['plurals'] == 3, 'Plural numbers changed.');
|
||||
$locale_plurals = \Drupal::service('locale.plural.formula')->reset()->getNumberOfPlurals('fr');
|
||||
$this->assertEqual(3, $locale_plurals, 'Plural numbers changed.');
|
||||
|
||||
// Importing a .po file and mark its strings as customized strings.
|
||||
$this->importPoFile($this->getCustomPoFile(), array(
|
||||
|
@ -238,8 +238,10 @@ class LocaleImportFunctionalTest extends WebTestBase {
|
|||
'langcode' => 'hr',
|
||||
));
|
||||
|
||||
$this->assertIdentical(t('May', array(), array('langcode' => 'hr', 'context' => 'Long month name')), 'Svibanj', 'Long month name context is working.');
|
||||
$this->assertIdentical(t('May', array(), array('langcode' => 'hr')), 'Svi.', 'Default context is working.');
|
||||
// We cast the return value of t() to string so as to retrieve the
|
||||
// translated value, rendered as a string.
|
||||
$this->assertIdentical((string) t('May', array(), array('langcode' => 'hr', 'context' => 'Long month name')), 'Svibanj', 'Long month name context is working.');
|
||||
$this->assertIdentical((string) t('May', array(), array('langcode' => 'hr')), 'Svi.', 'Default context is working.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -254,7 +256,7 @@ class LocaleImportFunctionalTest extends WebTestBase {
|
|||
));
|
||||
|
||||
$this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', array('%number' => 1, '%update' => 0, '%delete' => 0)), 'The translation file was successfully imported.');
|
||||
$this->assertIdentical(t('Operations', array(), array('langcode' => $langcode)), 'Műveletek', 'String imported and translated.');
|
||||
$this->assertIdentical((string) t('Operations', array(), array('langcode' => $langcode)), 'Műveletek', 'String imported and translated.');
|
||||
|
||||
// Try importing a .po file.
|
||||
$this->importPoFile($this->getPoFileWithEmptyMsgstr(), array(
|
||||
|
|
|
@ -23,7 +23,7 @@ class LocaleJavascriptTranslationTest extends WebTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('locale');
|
||||
public static $modules = array('locale', 'locale_test');
|
||||
|
||||
public function testFileParsing() {
|
||||
$filename = drupal_get_path('module', 'locale') . '/tests/locale_test.js';
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
namespace Drupal\locale\Tests;
|
||||
|
||||
use Drupal\Core\StringTranslation\PluralTranslatableMarkup;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
|
@ -130,12 +131,15 @@ class LocalePluralFormatTest extends WebTestBase {
|
|||
// expected index as per the logic for translation lookups.
|
||||
$expected_plural_index = ($count == 1) ? 0 : $expected_plural_index;
|
||||
$expected_plural_string = str_replace('@count', $count, $plural_strings[$langcode][$expected_plural_index]);
|
||||
$this->assertIdentical(\Drupal::translation()->formatPlural($count, '1 hour', '@count hours', array(), array('langcode' => $langcode)), $expected_plural_string, 'Plural translation of 1 hours / @count hours for count ' . $count . ' in ' . $langcode . ' is ' . $expected_plural_string);
|
||||
// DO NOT use translation to pass into formatPluralTranslated() this
|
||||
// way. It is designed to be used with *already* translated text like
|
||||
// settings from configuration. We use PHP translation here just because
|
||||
// we have the expected result data in that format.
|
||||
$this->assertIdentical(\Drupal::translation()->formatPluralTranslated($count, \Drupal::translation()->translate('1 hour' . LOCALE_PLURAL_DELIMITER . '@count hours', array(), array('langcode' => $langcode)), array(), array('langcode' => $langcode)), $expected_plural_string, 'Translated plural lookup of 1 hours / @count hours for count ' . $count . ' in ' . $langcode . ' is ' . $expected_plural_string);
|
||||
$this->assertIdentical(\Drupal::translation()->formatPlural($count, '1 hour', '@count hours', array(), array('langcode' => $langcode))->render(), $expected_plural_string, 'Plural translation of 1 hours / @count hours for count ' . $count . ' in ' . $langcode . ' is ' . $expected_plural_string);
|
||||
// DO NOT use translation to pass translated strings into
|
||||
// PluralTranslatableMarkup::createFromTranslatedString() this way. It
|
||||
// is designed to be used with *already* translated text like settings
|
||||
// from configuration. We use PHP translation here just because we have
|
||||
// the expected result data in that format.
|
||||
$translated_string = \Drupal::translation()->translate('1 hour' . PluralTranslatableMarkup::DELIMITER . '@count hours', array(), array('langcode' => $langcode));
|
||||
$plural = PluralTranslatableMarkup::createFromTranslatedString($count, $translated_string, array(), array('langcode' => $langcode));
|
||||
$this->assertIdentical($plural->render(), $expected_plural_string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -223,7 +227,7 @@ class LocalePluralFormatTest extends WebTestBase {
|
|||
// langcode here because the language will be English by default and will
|
||||
// not save our source string for performance optimization if we do not ask
|
||||
// specifically for a language.
|
||||
\Drupal::translation()->formatPlural(1, '1 day', '@count days', array(), array('langcode' => 'fr'));
|
||||
\Drupal::translation()->formatPlural(1, '1 day', '@count days', array(), array('langcode' => 'fr'))->render();
|
||||
$lid = db_query("SELECT lid FROM {locales_source} WHERE source = :source AND context = ''", array(':source' => "1 day" . LOCALE_PLURAL_DELIMITER . "@count days"))->fetchField();
|
||||
// Look up editing page for this plural string and check fields.
|
||||
$search = array(
|
||||
|
|
|
@ -19,7 +19,7 @@ class LocaleTranslationProjectsTest extends KernelTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['locale'];
|
||||
public static $modules = ['locale', 'locale_test'];
|
||||
|
||||
/**
|
||||
* The module handler used in this test.
|
||||
|
@ -43,6 +43,7 @@ class LocaleTranslationProjectsTest extends KernelTestBase {
|
|||
|
||||
$this->moduleHandler = $this->container->get('module_handler');
|
||||
$this->projectStorage = $this->container->get('locale.project');
|
||||
\Drupal::state()->set('locale.remove_core_project', TRUE);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ class LocaleTranslationUiTest extends WebTestBase {
|
|||
);
|
||||
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
|
||||
// Add string.
|
||||
t($name, array(), array('langcode' => $langcode));
|
||||
t($name, array(), array('langcode' => $langcode))->render();
|
||||
// Reset locale cache.
|
||||
$this->container->get('string_translation')->reset();
|
||||
$this->assertRaw('"edit-languages-' . $langcode . '-weight"', 'Language code found.');
|
||||
|
@ -237,9 +237,10 @@ class LocaleTranslationUiTest extends WebTestBase {
|
|||
|
||||
// Retrieve the source string of the first string available in the
|
||||
// {locales_source} table and translate it.
|
||||
$source = db_select('locales_source', 'l')
|
||||
->fields('l', array('source'))
|
||||
->condition('l.source', '%.js%', 'LIKE')
|
||||
$query = db_select('locales_source', 's');
|
||||
$query->addJoin('INNER', 'locales_location', 'l', 's.lid = l.lid');
|
||||
$source = $query->fields('s', array('source'))
|
||||
->condition('l.type', 'javascript')
|
||||
->range(0, 1)
|
||||
->execute()
|
||||
->fetchField();
|
||||
|
@ -302,7 +303,7 @@ class LocaleTranslationUiTest extends WebTestBase {
|
|||
);
|
||||
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
|
||||
// Add string.
|
||||
t($name, array(), array('langcode' => $langcode));
|
||||
t($name, array(), array('langcode' => $langcode))->render();
|
||||
// Reset locale cache.
|
||||
$search = array(
|
||||
'string' => $name,
|
||||
|
@ -361,7 +362,7 @@ class LocaleTranslationUiTest extends WebTestBase {
|
|||
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
|
||||
|
||||
// Add string.
|
||||
t($name, array(), array('langcode' => $langcode));
|
||||
t($name, array(), array('langcode' => $langcode))->render();
|
||||
// Reset locale cache.
|
||||
$this->container->get('string_translation')->reset();
|
||||
$this->drupalLogout();
|
||||
|
|
|
@ -50,7 +50,7 @@ abstract class LocaleUpdateBase extends WebTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('update', 'update_test', 'locale', 'locale_test');
|
||||
public static $modules = array('locale', 'locale_test');
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -58,11 +58,6 @@ abstract class LocaleUpdateBase extends WebTestBase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Update module should not go out to d.o to check for updates. We override
|
||||
// the url to the default update_test xml path. But without providing
|
||||
// a mock xml file, no update data will be found.
|
||||
$this->config('update.settings')->set('fetch.url', Url::fromRoute('update_test.update_test', [], ['absolute' => TRUE])->toString())->save();
|
||||
|
||||
// Setup timestamps to identify old and new translation sources.
|
||||
$this->timestampOld = REQUEST_TIME - 300;
|
||||
$this->timestampMedium = REQUEST_TIME - 200;
|
||||
|
@ -186,6 +181,7 @@ EOF;
|
|||
// A flag is set to let the locale_test module replace the project data with
|
||||
// a set of test projects which match the below project files.
|
||||
\Drupal::state()->set('locale.test_projects_alter', TRUE);
|
||||
\Drupal::state()->set('locale.remove_core_project', FALSE);
|
||||
|
||||
// Setup the environment.
|
||||
$public_path = PublicStream::basePath();
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\locale\Tests\LocaleUpdateDevelopmentReleaseTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\locale\Tests;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* Test for proper version fallback in case of a development release.
|
||||
*
|
||||
* @group language
|
||||
*/
|
||||
class LocaleUpdateDevelopmentReleaseTest extends WebTestBase {
|
||||
|
||||
public static $modules = array('locale', 'locale_test_development_release');
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
module_load_include('compare.inc', 'locale');
|
||||
$admin_user = $this->drupalCreateUser(array('administer modules', 'administer languages', 'access administration pages', 'translate interface'));
|
||||
$this->drupalLogin($admin_user);
|
||||
$this->drupalPostForm('admin/config/regional/language/add', array('predefined_langcode' => 'hu'), t('Add language'));
|
||||
}
|
||||
|
||||
public function testLocaleUpdateDevelopmentRelease() {
|
||||
$projects = locale_translation_build_projects();
|
||||
$this->verbose($projects['drupal']->info['version']);
|
||||
$this->assertEqual($projects['drupal']->info['version'], '8.0.x', 'The branch of the core dev release.');
|
||||
$this->verbose($projects['contrib']->info['version']);
|
||||
$this->assertEqual($projects['contrib']->info['version'], '12.x-10.x', 'The branch of the contrib module dev release.');
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
namespace Drupal\locale\Tests;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
|
||||
/**
|
||||
|
@ -45,7 +46,7 @@ class LocaleUpdateInterfaceTest extends LocaleUpdateBase {
|
|||
$this->assertNoText(t('Translation update status'), 'No status message');
|
||||
|
||||
$this->drupalGet('admin/reports/translations');
|
||||
$this->assertRaw(t('No translatable languages available. <a href="@add_language">Add a language</a> first.', array('@add_language' => \Drupal::url('entity.configurable_language.collection'))), 'Language message');
|
||||
$this->assertRaw(t('No translatable languages available. <a href=":add_language">Add a language</a> first.', array(':add_language' => \Drupal::url('entity.configurable_language.collection'))), 'Language message');
|
||||
|
||||
// Add German language.
|
||||
$this->addLanguage('de');
|
||||
|
@ -70,7 +71,7 @@ class LocaleUpdateInterfaceTest extends LocaleUpdateBase {
|
|||
// Check if updates are available for German.
|
||||
$this->drupalGet('admin/reports/status');
|
||||
$this->assertText(t('Translation update status'), 'Status message');
|
||||
$this->assertRaw(t('Updates available for: @languages. See the <a href="@updates">Available translation updates</a> page for more information.', array('@languages' => t('German'), '@updates' => \Drupal::url('locale.translate_status'))), 'Updates available message');
|
||||
$this->assertRaw(t('Updates available for: @languages. See the <a href=":updates">Available translation updates</a> page for more information.', array('@languages' => t('German'), ':updates' => \Drupal::url('locale.translate_status'))), 'Updates available message');
|
||||
$this->drupalGet('admin/reports/translations');
|
||||
$this->assertText(t('Updates for: @modules', array('@modules' => 'Locale test translate')), 'Translations available');
|
||||
|
||||
|
@ -84,11 +85,15 @@ class LocaleUpdateInterfaceTest extends LocaleUpdateBase {
|
|||
// Check if no updates were found.
|
||||
$this->drupalGet('admin/reports/status');
|
||||
$this->assertText(t('Translation update status'), 'Status message');
|
||||
$this->assertRaw(t('Missing translations for: @languages. See the <a href="@updates">Available translation updates</a> page for more information.', array('@languages' => t('German'), '@updates' => \Drupal::url('locale.translate_status'))), 'Missing translations message');
|
||||
$this->assertRaw(t('Missing translations for: @languages. See the <a href=":updates">Available translation updates</a> page for more information.', array('@languages' => t('German'), ':updates' => \Drupal::url('locale.translate_status'))), 'Missing translations message');
|
||||
$this->drupalGet('admin/reports/translations');
|
||||
$this->assertText(t('Missing translations for one project'), 'No translations found');
|
||||
$this->assertText(SafeMarkup::format('@module (@version). !info', array('@module' => 'Locale test translate', '@version' => '1.3-dev', '!info' => t('No translation files are provided for development releases.'))), 'Release details');
|
||||
$this->assertText(t('No translation files are provided for development releases.'), 'Release info');
|
||||
$release_details = new FormattableMarkup('@module (@version). @info', [
|
||||
'@module' => 'Locale test translate',
|
||||
'@version' => '1.3-dev',
|
||||
'@info' => t('File not found at %local_path', array('%local_path' => 'core/modules/locale/tests/test.de.po'))
|
||||
]);
|
||||
$this->assertRaw($release_details->__toString(), 'Release details');
|
||||
|
||||
// Override Drupal core translation status as 'no translations found'.
|
||||
$status = locale_translation_get_status();
|
||||
|
@ -111,7 +116,7 @@ class LocaleUpdateInterfaceTest extends LocaleUpdateBase {
|
|||
|
||||
// Check if translations are available for Drupal core.
|
||||
$this->drupalGet('admin/reports/translations');
|
||||
$this->assertText(t('Updates for: !project', array('!project' => t('Drupal core'))), 'Translations found');
|
||||
$this->assertText(t('Updates for: @project', array('@project' => t('Drupal core'))), 'Translations found');
|
||||
$this->assertText(SafeMarkup::format('@module (@date)', array('@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');
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\locale\Tests\LocaleUpdateNotDevelopmentReleaseTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\locale\Tests;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* Test for finding the first available normal core release version,
|
||||
* in case of core is a development release.
|
||||
*
|
||||
* @group language
|
||||
*/
|
||||
class LocaleUpdateNotDevelopmentReleaseTest extends WebTestBase {
|
||||
|
||||
public static $modules = array('update', 'locale', 'locale_test_not_development_release');
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
module_load_include('compare.inc', 'locale');
|
||||
$admin_user = $this->drupalCreateUser(array('administer modules', 'administer languages', 'access administration pages', 'translate interface'));
|
||||
$this->drupalLogin($admin_user);
|
||||
$this->drupalPostForm('admin/config/regional/language/add', array('predefined_langcode' => 'hu'), t('Add language'));
|
||||
}
|
||||
|
||||
public function testLocaleUpdateNotDevelopmentRelease() {
|
||||
// Set available Drupal releases for test.
|
||||
$available = array(
|
||||
'title' => 'Drupal core',
|
||||
'short_name' => 'drupal',
|
||||
'type' => 'project_core',
|
||||
'api_version' => '8.x',
|
||||
'project_status' => 'unsupported',
|
||||
'link' => 'https://www.drupal.org/project/drupal',
|
||||
'terms' => '',
|
||||
'releases' => array(
|
||||
'8.0.0-alpha110' => array(
|
||||
'name' => 'drupal 8.0.0-alpha110',
|
||||
'version' => '8.0.0-alpha110',
|
||||
'tag' => '8.0.0-alpha110',
|
||||
'version_major' => '8',
|
||||
'version_minor' => '0',
|
||||
'version_patch' => '0',
|
||||
'version_extra' => 'alpha110',
|
||||
'status' => 'published',
|
||||
'release_link' => 'https://www.drupal.org/node/2316617',
|
||||
'download_link' => 'http://ftp.drupal.org/files/projects/drupal-8.0.0-alpha110.tar.gz',
|
||||
'date' => '1407344628',
|
||||
'mdhash' => '9d71afdd0ce541f2ff5ca2fbbca00df7',
|
||||
'filesize' => '9172832',
|
||||
'files' => '',
|
||||
'terms' => array(),
|
||||
),
|
||||
'8.0.0-alpha100' => array(
|
||||
'name' => 'drupal 8.0.0-alpha100',
|
||||
'version' => '8.0.0-alpha100',
|
||||
'tag' => '8.0.0-alpha100',
|
||||
'version_major' => '8',
|
||||
'version_minor' => '0',
|
||||
'version_patch' => '0',
|
||||
'version_extra' => 'alpha100',
|
||||
'status' => 'published',
|
||||
'release_link' => 'https://www.drupal.org/node/2316617',
|
||||
'download_link' => 'http://ftp.drupal.org/files/projects/drupal-8.0.0-alpha100.tar.gz',
|
||||
'date' => '1407344628',
|
||||
'mdhash' => '9d71afdd0ce541f2ff5ca2fbbca00df7',
|
||||
'filesize' => '9172832',
|
||||
'files' => '',
|
||||
'terms' => array(),
|
||||
),
|
||||
),
|
||||
);
|
||||
$available['last_fetch'] = REQUEST_TIME;
|
||||
\Drupal::keyValueExpirable('update_available_releases')->setWithExpire('drupal', $available, 10);
|
||||
$projects = locale_translation_build_projects();
|
||||
$this->verbose($projects['drupal']->info['version']);
|
||||
$this->assertEqual($projects['drupal']->info['version'], '8.0.0-alpha110', 'The first release with the same major release number which is not a development release.');
|
||||
}
|
||||
}
|
|
@ -20,9 +20,7 @@ class MigrateLocaleConfigsTest extends MigrateDrupal6TestBase {
|
|||
use SchemaCheckTestTrait;
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = array('locale', 'language');
|
||||
|
||||
|
|
Reference in a new issue