Issue #1164926 by fastangel, good_man, Gábor Hojtsy: Fixed Nodes need to have languages specified separately for accessibility.
parent
129de63e06
commit
f8fc0dba31
|
@ -1175,3 +1175,26 @@ function locale_form_system_file_system_settings_alter(&$form, $form_state) {
|
|||
$form['file_default_scheme']['#weight'] = 20;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements MODULE_preprocess_HOOK().
|
||||
*/
|
||||
function locale_preprocess_node(&$variables) {
|
||||
if ($variables['language'] != LANGUAGE_NONE) {
|
||||
global $language;
|
||||
|
||||
$node_language = language_load($variables['language']);
|
||||
if ($node_language->language != $language->language) {
|
||||
// If the node language was different from the page language, we should
|
||||
// add markup to identify the language. Otherwise the page language is
|
||||
// inherited.
|
||||
$variables['attributes_array']['lang'] = $variables['language'];
|
||||
if ($node_language->direction != $language->direction) {
|
||||
// If text direction is different form the page's text direction, add
|
||||
// direction information as well.
|
||||
$dir = array('ltr', 'rtl');
|
||||
$variables['attributes_array']['dir'] = $dir[$node_language->direction];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -810,8 +810,7 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test automatic import of a module's translation files when a language is
|
||||
* enabled.
|
||||
* Test automatic import of a module's translation files.
|
||||
*/
|
||||
function testAutomaticModuleTranslationImportLanguageEnable() {
|
||||
// Code for the language - manually set to match the test translation file.
|
||||
|
@ -974,8 +973,7 @@ EOF;
|
|||
}
|
||||
|
||||
/**
|
||||
* Helper function that returns a proper .po file, for testing overwriting
|
||||
* existing translations.
|
||||
* Helper function that returns a proper .po file for testing.
|
||||
*/
|
||||
function getOverwritePoFile() {
|
||||
return <<< EOF
|
||||
|
@ -1864,8 +1862,7 @@ class LocaleContentFunctionalTest extends DrupalWebTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test if a content type can be set to multilingual and language setting is
|
||||
* present on node add and edit forms.
|
||||
* Test if a content type can be set to multilingual and language is present.
|
||||
*/
|
||||
function testContentTypeLanguageConfiguration() {
|
||||
global $base_url;
|
||||
|
@ -1956,10 +1953,92 @@ class LocaleContentFunctionalTest extends DrupalWebTestCase {
|
|||
|
||||
$this->drupalLogout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if a dir and lang tags exist in node's attributes.
|
||||
*/
|
||||
function testContentTypeDirLang() {
|
||||
// User to add and remove language.
|
||||
$admin_user = $this->drupalCreateUser(array('administer languages', 'administer content types', 'access administration pages'));
|
||||
// User to create a node.
|
||||
$web_user = $this->drupalCreateUser(array('create article content', 'edit own article content'));
|
||||
|
||||
// Login as admin.
|
||||
$this->drupalLogin($admin_user);
|
||||
|
||||
// Install Arabic language.
|
||||
$edit = array();
|
||||
$edit['predefined_langcode'] = 'ar';
|
||||
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
|
||||
|
||||
// Install Spanish language.
|
||||
$edit = array();
|
||||
$edit['predefined_langcode'] = 'es';
|
||||
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
|
||||
|
||||
// Set "Article" content type to use multilingual support.
|
||||
$this->drupalGet('admin/structure/types/manage/article');
|
||||
$edit = array(
|
||||
'language_content_type' => 1,
|
||||
);
|
||||
$this->drupalPost('admin/structure/types/manage/article', $edit, t('Save content type'));
|
||||
$this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Article')), t('Article content type has been updated.'));
|
||||
$this->drupalLogout();
|
||||
|
||||
// Login as web user to add new article.
|
||||
$this->drupalLogin($web_user);
|
||||
|
||||
// Create three nodes: English, Arabic and Spanish.
|
||||
$node_en = $this->createNodeArticle('en');
|
||||
$node_ar = $this->createNodeArticle('ar');
|
||||
$node_es = $this->createNodeArticle('es');
|
||||
|
||||
$this->drupalGet('node');
|
||||
|
||||
// Check if English node does not have lang tag.
|
||||
$pattern = '|id="node-' . $node_en->nid . '"[^<>]*lang="en"|';
|
||||
$this->assertNoPattern($pattern, t('The lang tag has not been assigned to the English node.'));
|
||||
|
||||
// Check if English node does not have dir tag.
|
||||
$pattern = '|id="node-' . $node_en->nid . '"[^<>]*dir="ltr"|';
|
||||
$this->assertNoPattern($pattern, t('The dir tag has not been assigned to the English node.'));
|
||||
|
||||
// Check if Arabic node has lang="ar" & dir="rtl" tags.
|
||||
$pattern = '|id="node-' . $node_ar->nid . '"[^<>]*lang="ar" dir="rtl"|';
|
||||
$this->assertPattern($pattern, t('The lang and dir tags have been assigned correctly to the Arabic node.'));
|
||||
|
||||
// Check if Spanish node has lang="es" tag.
|
||||
$pattern = '|id="node-' . $node_es->nid . '"[^<>]*lang="es"|';
|
||||
$this->assertPattern($pattern, t('The lang tag has been assigned correctly to the Spanish node.'));
|
||||
|
||||
// Check if Spanish node does not have dir="ltr" tag.
|
||||
$pattern = '|id="node-' . $node_es->nid . '"[^<>]*lang="es" dir="ltr"|';
|
||||
$this->assertNoPattern($pattern, t('The dir tag has not been assigned to the Spanish node.'));
|
||||
|
||||
$this->drupalLogout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create node in a specific language.
|
||||
*/
|
||||
protected function createNodeArticle($langcode) {
|
||||
$this->drupalGet('node/add/article');
|
||||
$node_title = $this->randomName();
|
||||
$node_body = $this->randomName();
|
||||
$edit = array(
|
||||
'type' => 'article',
|
||||
'title' => $node_title,
|
||||
'body' => array($langcode => array(array('value' => $node_body))),
|
||||
'language' => $langcode,
|
||||
'promote' => 1,
|
||||
);
|
||||
return $this->drupalCreateNode($edit);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test UI language negotiation
|
||||
*
|
||||
* 1. URL (PATH) > DEFAULT
|
||||
* UI Language base on URL prefix, browser language preference has no
|
||||
* influence:
|
||||
|
@ -2149,7 +2228,7 @@ class LocaleUILanguageNegotiationTest extends DrupalWebTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
private function runTest($test) {
|
||||
protected function runTest($test) {
|
||||
if (!empty($test['language_negotiation'])) {
|
||||
$negotiation = array_flip($test['language_negotiation']);
|
||||
language_negotiation_set(LANGUAGE_TYPE_INTERFACE, $negotiation);
|
||||
|
@ -2508,6 +2587,7 @@ class LocaleCommentLanguageFunctionalTest extends DrupalWebTestCase {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Functional tests for localizing date formats.
|
||||
*/
|
||||
|
@ -2691,7 +2771,7 @@ class LocaleLanguageNegotiationInfoFunctionalTest extends DrupalWebTestCase {
|
|||
* they would not be invoked after enabling/disabling locale_test the first
|
||||
* time.
|
||||
*/
|
||||
private function languageNegotiationUpdate($op = 'enable') {
|
||||
protected function languageNegotiationUpdate($op = 'enable') {
|
||||
static $last_op = NULL;
|
||||
$modules = array('locale_test');
|
||||
|
||||
|
@ -2716,7 +2796,7 @@ class LocaleLanguageNegotiationInfoFunctionalTest extends DrupalWebTestCase {
|
|||
/**
|
||||
* Check that language negotiation for fixed types matches the stored one.
|
||||
*/
|
||||
private function checkFixedLanguageTypes() {
|
||||
protected function checkFixedLanguageTypes() {
|
||||
drupal_static_reset('language_types_info');
|
||||
foreach (language_types_info() as $type => $info) {
|
||||
if (isset($info['fixed'])) {
|
||||
|
|
Loading…
Reference in New Issue