Issue #2533746 by Gábor Hojtsy, webflo, tstoeckler, Jose Reyero: Remove the the ability to translate locked date formats (e.g. html_datetime)
parent
ed3bc9bf97
commit
8f028e644e
|
|
@ -421,9 +421,19 @@ core.date_format.*:
|
||||||
type: boolean
|
type: boolean
|
||||||
label: 'Locked'
|
label: 'Locked'
|
||||||
pattern:
|
pattern:
|
||||||
type: date_format
|
type: core_date_format_pattern.[%parent.locked]
|
||||||
label: 'PHP date format'
|
label: 'PHP date format'
|
||||||
|
|
||||||
|
# Unlocked date formats should use the translatable type.
|
||||||
|
core_date_format_pattern.0:
|
||||||
|
type: date_format
|
||||||
|
label: 'Date format'
|
||||||
|
|
||||||
|
# Locked date formats are just used to transport the value.
|
||||||
|
core_date_format_pattern.1:
|
||||||
|
type: string
|
||||||
|
label: 'Date format'
|
||||||
|
|
||||||
# Generic field settings schemas.
|
# Generic field settings schemas.
|
||||||
|
|
||||||
field.storage_settings.*:
|
field.storage_settings.*:
|
||||||
|
|
|
||||||
|
|
@ -282,8 +282,12 @@ class TypedConfigManager extends TypedDataManager implements TypedConfigManagerI
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
elseif (!$parts) {
|
elseif (!$parts) {
|
||||||
|
$value = $data[$name];
|
||||||
|
if (is_bool($value)) {
|
||||||
|
$value = (int) $value;
|
||||||
|
}
|
||||||
// If no more parts left, this is the final property.
|
// If no more parts left, this is the final property.
|
||||||
return (string)$data[$name];
|
return (string) $value;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Get nested value and continue processing.
|
// Get nested value and continue processing.
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Contains \Drupal\config_translation\Tests\ConfigTranslationDateFormatUiTest.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Drupal\config_translation\Tests;
|
||||||
|
|
||||||
|
use Drupal\language\Entity\ConfigurableLanguage;
|
||||||
|
use Drupal\simpletest\WebTestBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the content translation behaviours on date formats.
|
||||||
|
*
|
||||||
|
* @group config_translation
|
||||||
|
*/
|
||||||
|
class ConfigTranslationDateFormatUiTest extends WebTestBase {
|
||||||
|
|
||||||
|
public static $modules = array(
|
||||||
|
'language',
|
||||||
|
'config_translation',
|
||||||
|
'system'
|
||||||
|
);
|
||||||
|
|
||||||
|
protected function setUp() {
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
// Enable additional languages.
|
||||||
|
$langcodes = ['de', 'es'];
|
||||||
|
foreach ($langcodes as $langcode) {
|
||||||
|
ConfigurableLanguage::createFromLangcode($langcode)->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = $this->drupalCreateUser(array(
|
||||||
|
'administer site configuration',
|
||||||
|
'translate configuration',
|
||||||
|
));
|
||||||
|
$this->drupalLogin($user);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests date format translation behaviour.
|
||||||
|
*/
|
||||||
|
public function testDateFormatUI() {
|
||||||
|
$this->drupalGet('admin/config/regional/date-time');
|
||||||
|
|
||||||
|
// Assert translation link unlocked date format.
|
||||||
|
$this->assertLinkByHref('admin/config/regional/date-time/formats/manage/medium/translate');
|
||||||
|
|
||||||
|
// Assert translation link locked date format.
|
||||||
|
$this->assertLinkByHref('admin/config/regional/date-time/formats/manage/html_datetime/translate');
|
||||||
|
|
||||||
|
// Date pattern is visible on unlocked date formats.
|
||||||
|
$this->drupalGet('admin/config/regional/date-time/formats/manage/medium/translate/de/add');
|
||||||
|
$this->assertField('translation[config_names][core.date_format.medium][pattern]');
|
||||||
|
|
||||||
|
// Date pattern is not visible on locked date formats.
|
||||||
|
$this->drupalGet('admin/config/regional/date-time/formats/manage/html_datetime/translate/es/add');
|
||||||
|
$this->assertNoField('translation[config_names][core.date_format.html_datetime][pattern]');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue