Issue #2070737 by herom, EllaTheHarpy, alexpott: Change values of LanguageInterface::DIRECTION_(LTR/RTL) to ('ltr'/'rtl').
parent
e3964f9a2c
commit
7476af9004
|
@ -1798,7 +1798,6 @@ function template_preprocess_page(&$variables) {
|
|||
$variables['base_path'] = base_path();
|
||||
$variables['front_page'] = \Drupal::url('<front>');
|
||||
$variables['language'] = $language_interface;
|
||||
$variables['language']->dir = $language_interface->direction ? 'rtl' : 'ltr';
|
||||
$variables['logo'] = theme_get_setting('logo.url');
|
||||
$variables['site_name'] = (theme_get_setting('features.name') ? String::checkPlain($site_config->get('name')) : '');
|
||||
$variables['site_slogan'] = (theme_get_setting('features.slogan') ? Xss::filterAdmin($site_config->get('slogan')) : '');
|
||||
|
|
|
@ -50,7 +50,7 @@ class Language implements LanguageInterface {
|
|||
*
|
||||
* @var int
|
||||
*/
|
||||
public $direction = self::DIRECTION_LTR;
|
||||
protected $direction = self::DIRECTION_LTR;
|
||||
|
||||
/**
|
||||
* The weight, used for ordering languages in lists, like selects or tables.
|
||||
|
|
|
@ -94,12 +94,12 @@ interface LanguageInterface {
|
|||
/**
|
||||
* Language written left to right. Possible value of $language->direction.
|
||||
*/
|
||||
const DIRECTION_LTR = 0;
|
||||
const DIRECTION_LTR = 'ltr';
|
||||
|
||||
/**
|
||||
* Language written right to left. Possible value of $language->direction.
|
||||
*/
|
||||
const DIRECTION_RTL = 1;
|
||||
const DIRECTION_RTL = 'rtl';
|
||||
|
||||
/**
|
||||
* Gets the name of the language.
|
||||
|
@ -120,7 +120,7 @@ interface LanguageInterface {
|
|||
/**
|
||||
* Gets the text direction (left-to-right or right-to-left).
|
||||
*
|
||||
* @return int
|
||||
* @return string
|
||||
* Either self::DIRECTION_LTR or self::DIRECTION_RTL.
|
||||
*/
|
||||
public function getDirection();
|
||||
|
|
|
@ -101,7 +101,7 @@ class DefaultHtmlFragmentRenderer implements HtmlFragmentRendererInterface {
|
|||
$language_interface = $this->languageManager->getCurrentLanguage();
|
||||
$html_attributes = $page->getHtmlAttributes();
|
||||
$html_attributes['lang'] = $language_interface->id;
|
||||
$html_attributes['dir'] = $language_interface->direction ? 'rtl' : 'ltr';
|
||||
$html_attributes['dir'] = $language_interface->getDirection();
|
||||
|
||||
$this->setDefaultMetaTags($page);
|
||||
|
||||
|
|
|
@ -478,13 +478,13 @@ function template_preprocess_book_export_html(&$variables) {
|
|||
$variables['title'] = String::checkPlain($variables['title']);
|
||||
$variables['base_url'] = $base_url;
|
||||
$variables['language'] = $language_interface;
|
||||
$variables['language_rtl'] = ($language_interface->direction == LanguageInterface::DIRECTION_RTL);
|
||||
$variables['language_rtl'] = ($language_interface->getDirection() == LanguageInterface::DIRECTION_RTL);
|
||||
$variables['head'] = drupal_get_html_head();
|
||||
|
||||
// HTML element attributes.
|
||||
$attributes = array();
|
||||
$attributes['lang'] = $language_interface->id;
|
||||
$attributes['dir'] = $language_interface->direction ? 'rtl' : 'ltr';
|
||||
$attributes['dir'] = $language_interface->getDirection();
|
||||
$variables['html_attributes'] = new Attribute($attributes);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
use Drupal\Core\Template\Attribute;
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
|
||||
/**
|
||||
* Prepares variables for CKEditor settings toolbar templates.
|
||||
|
@ -19,9 +20,7 @@ use Drupal\Component\Utility\SafeMarkup;
|
|||
* - plugins: A list of plugins.
|
||||
*/
|
||||
function template_preprocess_ckeditor_settings_toolbar(&$variables) {
|
||||
// Simplify the language direction information for toolbar buttons.
|
||||
$language_interface = \Drupal::languageManager()->getCurrentLanguage();
|
||||
$language_direction = $language_interface->direction ? 'rtl' : 'ltr';
|
||||
|
||||
// Create lists of active and disabled buttons.
|
||||
$editor = $variables['editor'];
|
||||
|
@ -61,7 +60,7 @@ function template_preprocess_ckeditor_settings_toolbar(&$variables) {
|
|||
}
|
||||
$disabled_buttons = array_diff_key($buttons, $multiple_buttons);
|
||||
|
||||
$rtl = $language_direction === 'rtl' ? '_rtl' : '';
|
||||
$rtl = $language_interface->getDirection() === LanguageInterface::DIRECTION_RTL ? '_rtl' : '';
|
||||
|
||||
$build_button_item = function($button, $rtl) {
|
||||
// Value of the button item.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
id: en
|
||||
label: English
|
||||
direction: 0
|
||||
direction: 'ltr'
|
||||
weight: 0
|
||||
locked: false
|
||||
status: true
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
id: und
|
||||
label: 'Not specified'
|
||||
direction: 0
|
||||
direction: 'ltr'
|
||||
weight: 1
|
||||
locked: true
|
||||
status: true
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
id: zxx
|
||||
label: 'Not applicable'
|
||||
direction: 0
|
||||
direction: 'ltr'
|
||||
weight: 2
|
||||
locked: true
|
||||
status: true
|
||||
|
|
|
@ -92,7 +92,7 @@ language.entity.*:
|
|||
type: label
|
||||
label: 'Label'
|
||||
direction:
|
||||
type: integer
|
||||
type: string
|
||||
label: 'Direction'
|
||||
weight:
|
||||
type: integer
|
||||
|
|
|
@ -64,7 +64,7 @@ class ConfigurableLanguage extends ConfigEntityBase implements ConfigurableLangu
|
|||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $direction = '';
|
||||
protected $direction = self::DIRECTION_LTR;
|
||||
|
||||
/**
|
||||
* The weight of the language, used in lists of languages.
|
||||
|
|
|
@ -43,7 +43,7 @@ class LanguageCustomLanguageConfigurationTest extends WebTestBase {
|
|||
$this->assertText(t('!name field is required.', array('!name' => t('Language code'))));
|
||||
$this->assertText(t('!name field is required.', array('!name' => t('Language name in English'))));
|
||||
$empty_language = new Language();
|
||||
$this->assertFieldChecked('edit-direction-' . $empty_language->direction, 'Consistent usage of language direction.');
|
||||
$this->assertFieldChecked('edit-direction-' . $empty_language->getDirection(), 'Consistent usage of language direction.');
|
||||
$this->assertUrl(\Drupal::url('language.add', array(), array('absolute' => TRUE)), [], 'Correct page redirection.');
|
||||
|
||||
// Test validation of invalid values.
|
||||
|
|
|
@ -557,7 +557,7 @@ function locale_library_alter(array &$library, $name) {
|
|||
|
||||
$language_interface = \Drupal::languageManager()->getCurrentLanguage();
|
||||
$settings['jquery']['ui']['datepicker'] = array(
|
||||
'isRTL' => $language_interface->direction == LanguageInterface::DIRECTION_RTL,
|
||||
'isRTL' => $language_interface->getDirection() == LanguageInterface::DIRECTION_RTL,
|
||||
'firstDay' => \Drupal::config('system.date')->get('first_day'),
|
||||
);
|
||||
$library['js'][] = array(
|
||||
|
@ -738,11 +738,10 @@ function locale_preprocess_node(&$variables) {
|
|||
// add markup to identify the language. Otherwise the page language is
|
||||
// inherited.
|
||||
$variables['attributes']['lang'] = $node_language->id;
|
||||
if ($node_language->direction != $language_interface->direction) {
|
||||
if ($node_language->getDirection() != $language_interface->getDirection()) {
|
||||
// If text direction is different form the page's text direction, add
|
||||
// direction information as well.
|
||||
$dir = array('ltr', 'rtl');
|
||||
$variables['attributes']['dir'] = $dir[$node_language->direction];
|
||||
$variables['attributes']['dir'] = $node_language->getDirection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -248,7 +248,7 @@ function hook_library_alter(array &$library, $name) {
|
|||
|
||||
$language_interface = \Drupal::languageManager()->getCurrentLanguage();
|
||||
$settings['jquery']['ui']['datepicker'] = array(
|
||||
'isRTL' => $language_interface->direction == LanguageInterface::DIRECTION_RTL,
|
||||
'isRTL' => $language_interface->getDirection() == LanguageInterface::DIRECTION_RTL,
|
||||
'firstDay' => \Drupal::config('system.date')->get('first_day'),
|
||||
);
|
||||
$library['js'][] = array(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
id: de
|
||||
label: German
|
||||
direction: 0
|
||||
direction: 'ltr'
|
||||
weight: 0
|
||||
locked: false
|
||||
status: true
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
id: es
|
||||
label: Spanish
|
||||
direction: 0
|
||||
direction: 'ltr'
|
||||
weight: 0
|
||||
locked: false
|
||||
status: true
|
||||
|
|
Loading…
Reference in New Issue