summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwebchick2012-08-27 03:25:18 (GMT)
committerwebchick2012-08-27 03:25:18 (GMT)
commit44fc81a2777a586a783190ce01f68818e15bb86e (patch)
tree589bae74a435ad80390d77cb4ba7e384bfdadf75
parent7d7aa9797f5e5c370fb5dc3458d12ebd4434e493 (diff)
Issue #1305378 by bforchhammer, penyaskito, k4v, Schnitzel, Gábor Hojtsy, Dave Reid: Added Tokens should use $options["langcode"] and not need a language object.
-rw-r--r--core/includes/mail.inc2
-rw-r--r--core/includes/token.inc4
-rw-r--r--core/modules/comment/comment.tokens.inc6
-rw-r--r--core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php6
-rw-r--r--core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php4
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php4
-rw-r--r--core/modules/node/node.tokens.inc16
-rw-r--r--core/modules/poll/lib/Drupal/poll/Tests/PollTokenReplaceTest.php4
-rw-r--r--core/modules/poll/poll.tokens.inc10
-rw-r--r--core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php2
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php12
-rw-r--r--core/modules/system/system.api.php20
-rw-r--r--core/modules/system/system.tokens.inc20
-rw-r--r--core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php10
-rw-r--r--core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php16
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php4
-rw-r--r--core/modules/user/user.tokens.inc6
17 files changed, 73 insertions, 73 deletions
diff --git a/core/includes/mail.inc b/core/includes/mail.inc
index b875f92..7170deb 100644
--- a/core/includes/mail.inc
+++ b/core/includes/mail.inc
@@ -53,7 +53,7 @@ define('MAIL_LINE_ENDINGS', isset($_SERVER['WINDIR']) || strpos($_SERVER['SERVER
*
* function example_mail($key, &$message, $params) {
* $data['user'] = $params['account'];
- * $options['language'] = $message['language'];
+ * $options['langcode'] = $message['language'];
* user_mail_tokens($variables, $data, $options);
* switch($key) {
* case 'notice':
diff --git a/core/includes/token.inc b/core/includes/token.inc
index 5c74519..a6f8064 100644
--- a/core/includes/token.inc
+++ b/core/includes/token.inc
@@ -59,7 +59,7 @@
* @param $options
* (optional) A keyed array of settings and flags to control the token
* replacement process. Supported options are:
- * - language: A language object to be used when generating locale-sensitive
+ * - langcode: A language code to be used when generating locale-sensitive
* tokens.
* - callback: A callback function that will be used to post-process the array
* of token replacements after they are generated. For example, a module
@@ -154,7 +154,7 @@ function token_scan($text) {
* @param $options
* (optional) A keyed array of settings and flags to control the token
* replacement process. Supported options are:
- * - language: A language object to be used when generating locale-sensitive
+ * - langcode: A language code to be used when generating locale-sensitive
* tokens.
* - callback: A callback function that will be used to post-process the
* array of token replacements after they are generated. Can be used when
diff --git a/core/modules/comment/comment.tokens.inc b/core/modules/comment/comment.tokens.inc
index 318c1b6..c77cb67 100644
--- a/core/modules/comment/comment.tokens.inc
+++ b/core/modules/comment/comment.tokens.inc
@@ -104,9 +104,9 @@ function comment_token_info() {
*/
function comment_tokens($type, $tokens, array $data = array(), array $options = array()) {
$url_options = array('absolute' => TRUE);
- if (isset($options['language'])) {
- $url_options['language'] = $options['language'];
- $langcode = $options['language']->langcode;
+ if (isset($options['langcode'])) {
+ $url_options['language'] = language_load($options['langcode']);
+ $langcode = $options['langcode'];
}
else {
$langcode = NULL;
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php
index 383786c..caf22c7 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php
@@ -72,7 +72,7 @@ class CommentTokenReplaceTest extends CommentTestBase {
$this->assertFalse(in_array(0, array_map('strlen', $tests)), t('No empty tokens generated.'));
foreach ($tests as $input => $expected) {
- $output = token_replace($input, array('comment' => $comment), array('language' => $language_interface));
+ $output = token_replace($input, array('comment' => $comment), array('langcode' => $language_interface->langcode));
$this->assertEqual($output, $expected, t('Sanitized comment token %token replaced.', array('%token' => $input)));
}
@@ -88,7 +88,7 @@ class CommentTokenReplaceTest extends CommentTestBase {
$tests['[comment:author:name]'] = $this->admin_user->name;
foreach ($tests as $input => $expected) {
- $output = token_replace($input, array('comment' => $comment), array('language' => $language_interface, 'sanitize' => FALSE));
+ $output = token_replace($input, array('comment' => $comment), array('langcode' => $language_interface->langcode, 'sanitize' => FALSE));
$this->assertEqual($output, $expected, t('Unsanitized comment token %token replaced.', array('%token' => $input)));
}
@@ -101,7 +101,7 @@ class CommentTokenReplaceTest extends CommentTestBase {
$tests['[node:comment-count-new]'] = 2;
foreach ($tests as $input => $expected) {
- $output = token_replace($input, array('node' => $node), array('language' => $language_interface));
+ $output = token_replace($input, array('node' => $node), array('langcode' => $language_interface->langcode));
$this->assertEqual($output, $expected, t('Node comment token %token replaced.', array('%token' => $input)));
}
}
diff --git a/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php b/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php
index 2781723..4d56b7b 100644
--- a/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php
@@ -65,7 +65,7 @@ class FileTokenReplaceTest extends FileFieldTestBase {
$this->assertFalse(in_array(0, array_map('strlen', $tests)), t('No empty tokens generated.'));
foreach ($tests as $input => $expected) {
- $output = token_replace($input, array('file' => $file), array('language' => $language_interface));
+ $output = token_replace($input, array('file' => $file), array('langcode' => $language_interface->langcode));
$this->assertEqual($output, $expected, t('Sanitized file token %token replaced.', array('%token' => $input)));
}
@@ -76,7 +76,7 @@ class FileTokenReplaceTest extends FileFieldTestBase {
$tests['[file:size]'] = format_size($file->filesize);
foreach ($tests as $input => $expected) {
- $output = token_replace($input, array('file' => $file), array('language' => $language_interface, 'sanitize' => FALSE));
+ $output = token_replace($input, array('file' => $file), array('langcode' => $language_interface->langcode, 'sanitize' => FALSE));
$this->assertEqual($output, $expected, t('Unsanitized file token %token replaced.', array('%token' => $input)));
}
}
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php
index 4174ee6..34f8e4a 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php
@@ -66,7 +66,7 @@ class NodeTokenReplaceTest extends NodeTestBase {
$this->assertFalse(in_array(0, array_map('strlen', $tests)), t('No empty tokens generated.'));
foreach ($tests as $input => $expected) {
- $output = token_replace($input, array('node' => $node), array('language' => $language_interface));
+ $output = token_replace($input, array('node' => $node), array('langcode' => $language_interface->langcode));
$this->assertEqual($output, $expected, t('Sanitized node token %token replaced.', array('%token' => $input)));
}
@@ -78,7 +78,7 @@ class NodeTokenReplaceTest extends NodeTestBase {
$tests['[node:author:name]'] = user_format_name($account);
foreach ($tests as $input => $expected) {
- $output = token_replace($input, array('node' => $node), array('language' => $language_interface, 'sanitize' => FALSE));
+ $output = token_replace($input, array('node' => $node), array('langcode' => $language_interface->langcode, 'sanitize' => FALSE));
$this->assertEqual($output, $expected, t('Unsanitized node token %token replaced.', array('%token' => $input)));
}
}
diff --git a/core/modules/node/node.tokens.inc b/core/modules/node/node.tokens.inc
index 1b37fc8..ce44ffe 100644
--- a/core/modules/node/node.tokens.inc
+++ b/core/modules/node/node.tokens.inc
@@ -91,12 +91,12 @@ function node_token_info() {
*/
function node_tokens($type, $tokens, array $data = array(), array $options = array()) {
$url_options = array('absolute' => TRUE);
- if (isset($options['language'])) {
- $url_options['language'] = $options['language'];
- $language_code = $options['language']->langcode;
+ if (isset($options['langcode'])) {
+ $url_options['language'] = language_load($options['langcode']);
+ $langcode = $options['langcode'];
}
else {
- $language_code = NULL;
+ $langcode = NULL;
}
$sanitize = !empty($options['sanitize']);
@@ -135,10 +135,10 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr
case 'body':
case 'summary':
- if ($items = field_get_items('node', $node, 'body', $language_code)) {
+ if ($items = field_get_items('node', $node, 'body', $langcode)) {
$column = ($name == 'body') ? 'value' : 'summary';
$instance = field_info_instance('node', 'body', $node->type);
- $field_langcode = field_language('node', $node, 'body', $language_code);
+ $field_langcode = field_language('node', $node, 'body', $langcode);
$replacements[$original] = $sanitize ? _text_sanitize($instance, $field_langcode, $items[0], $column) : $items[0][$column];
}
break;
@@ -163,11 +163,11 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr
break;
case 'created':
- $replacements[$original] = format_date($node->created, 'medium', '', NULL, $language_code);
+ $replacements[$original] = format_date($node->created, 'medium', '', NULL, $langcode);
break;
case 'changed':
- $replacements[$original] = format_date($node->changed, 'medium', '', NULL, $language_code);
+ $replacements[$original] = format_date($node->changed, 'medium', '', NULL, $langcode);
break;
}
}
diff --git a/core/modules/poll/lib/Drupal/poll/Tests/PollTokenReplaceTest.php b/core/modules/poll/lib/Drupal/poll/Tests/PollTokenReplaceTest.php
index 7d0fddf..8096756 100644
--- a/core/modules/poll/lib/Drupal/poll/Tests/PollTokenReplaceTest.php
+++ b/core/modules/poll/lib/Drupal/poll/Tests/PollTokenReplaceTest.php
@@ -78,7 +78,7 @@ class PollTokenReplaceTest extends PollTestBase {
$this->assertFalse(in_array(0, array_map('strlen', $tests)), t('No empty tokens generated.'));
foreach ($tests as $input => $expected) {
- $output = token_replace($input, array('node' => $poll), array('language' => $language_interface));
+ $output = token_replace($input, array('node' => $poll), array('langcode' => $language_interface->langcode));
$this->assertEqual($output, $expected, t('Sanitized poll token %token replaced.', array('%token' => $input)));
}
@@ -86,7 +86,7 @@ class PollTokenReplaceTest extends PollTestBase {
$tests['[node:poll-winner]'] = $poll->choice[1]['chtext'];
foreach ($tests as $input => $expected) {
- $output = token_replace($input, array('node' => $poll), array('language' => $language_interface, 'sanitize' => FALSE));
+ $output = token_replace($input, array('node' => $poll), array('langcode' => $language_interface->langcode, 'sanitize' => FALSE));
$this->assertEqual($output, $expected, t('Unsanitized poll token %token replaced.', array('%token' => $input)));
}
}
diff --git a/core/modules/poll/poll.tokens.inc b/core/modules/poll/poll.tokens.inc
index 4226a69..e0f9b2b 100644
--- a/core/modules/poll/poll.tokens.inc
+++ b/core/modules/poll/poll.tokens.inc
@@ -40,12 +40,12 @@ function poll_token_info() {
*/
function poll_tokens($type, $tokens, array $data = array(), array $options = array()) {
$sanitize = !empty($options['sanitize']);
- if (isset($options['language'])) {
- $url_options['language'] = $options['language'];
- $language_code = $options['language']->langcode;
+ if (isset($options['langcode'])) {
+ $url_options['language'] = language_load($options['langcode']);
+ $langcode = $options['langcode'];
}
else {
- $language_code = NULL;
+ $langcode = NULL;
}
$replacements = array();
@@ -97,7 +97,7 @@ function poll_tokens($type, $tokens, array $data = array(), array $options = arr
break;
case 'poll-duration':
- $replacements[$original] = format_interval($node->runtime, 1, $language_code);
+ $replacements[$original] = format_interval($node->runtime, 1, $langcode);
break;
}
}
diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php
index 516c292..0f68140 100644
--- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php
+++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php
@@ -52,7 +52,7 @@ class StatisticsTokenReplaceTest extends StatisticsTestBase {
$this->assertFalse(in_array(0, array_map('strlen', $tests)), t('No empty tokens generated.'));
foreach ($tests as $input => $expected) {
- $output = token_replace($input, array('node' => $node), array('language' => $language_interface));
+ $output = token_replace($input, array('node' => $node), array('langcode' => $language_interface->langcode));
$this->assertEqual($output, $expected, t('Statistics token %token replaced.', array('%token' => $input)));
}
}
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php b/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php
index 16eb0f2..79bea6b 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php
@@ -47,13 +47,13 @@ class TokenReplaceTest extends WebTestBase {
$target .= format_date(REQUEST_TIME, 'short', '', NULL, $language_interface->langcode);
// Test that the clear parameter cleans out non-existent tokens.
- $result = token_replace($source, array('node' => $node), array('language' => $language_interface, 'clear' => TRUE));
+ $result = token_replace($source, array('node' => $node), array('langcode' => $language_interface->langcode, 'clear' => TRUE));
$result = $this->assertEqual($target, $result, 'Valid tokens replaced while invalid tokens cleared out.');
// Test without using the clear parameter (non-existent token untouched).
$target .= '[user:name]';
$target .= '[bogus:token]';
- $result = token_replace($source, array('node' => $node), array('language' => $language_interface));
+ $result = token_replace($source, array('node' => $node), array('langcode' => $language_interface->langcode));
$this->assertEqual($target, $result, 'Valid tokens replaced while invalid tokens ignored.');
// Check that the results of token_generate are sanitized properly. This does NOT
@@ -95,7 +95,7 @@ class TokenReplaceTest extends WebTestBase {
foreach ($tests as $test) {
$input = $test['prefix'] . '[site:name]' . $test['suffix'];
$expected = $test['prefix'] . 'Drupal' . $test['suffix'];
- $output = token_replace($input, array(), array('language' => $language_interface));
+ $output = token_replace($input, array(), array('langcode' => $language_interface->langcode));
$this->assertTrue($output == $expected, t('Token recognized in string %string', array('%string' => $input)));
}
}
@@ -129,7 +129,7 @@ class TokenReplaceTest extends WebTestBase {
$this->assertFalse(in_array(0, array_map('strlen', $tests)), t('No empty tokens generated.'));
foreach ($tests as $input => $expected) {
- $output = token_replace($input, array(), array('language' => $language_interface));
+ $output = token_replace($input, array(), array('langcode' => $language_interface->langcode));
$this->assertEqual($output, $expected, t('Sanitized system site information token %token replaced.', array('%token' => $input)));
}
@@ -138,7 +138,7 @@ class TokenReplaceTest extends WebTestBase {
$tests['[site:slogan]'] = config('system.site')->get('slogan');
foreach ($tests as $input => $expected) {
- $output = token_replace($input, array(), array('language' => $language_interface, 'sanitize' => FALSE));
+ $output = token_replace($input, array(), array('langcode' => $language_interface->langcode, 'sanitize' => FALSE));
$this->assertEqual($output, $expected, t('Unsanitized system site information token %token replaced.', array('%token' => $input)));
}
}
@@ -165,7 +165,7 @@ class TokenReplaceTest extends WebTestBase {
$this->assertFalse(in_array(0, array_map('strlen', $tests)), t('No empty tokens generated.'));
foreach ($tests as $input => $expected) {
- $output = token_replace($input, array('date' => $date), array('language' => $language_interface));
+ $output = token_replace($input, array('date' => $date), array('langcode' => $language_interface->langcode));
$this->assertEqual($output, $expected, t('Date token %token replaced.', array('%token' => $input)));
}
}
diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php
index b020db9..de8a2ae 100644
--- a/core/modules/system/system.api.php
+++ b/core/modules/system/system.api.php
@@ -3754,12 +3754,12 @@ function hook_url_outbound_alter(&$path, &$options, $original_path) {
*/
function hook_tokens($type, $tokens, array $data = array(), array $options = array()) {
$url_options = array('absolute' => TRUE);
- if (isset($options['language'])) {
- $url_options['language'] = $options['language'];
- $language_code = $options['language']->langcode;
+ if (isset($options['langcode'])) {
+ $url_options['language'] = language_load($options['langcode']);
+ $langcode = $options['langcode'];
}
else {
- $language_code = NULL;
+ $langcode = NULL;
}
$sanitize = !empty($options['sanitize']);
@@ -3790,7 +3790,7 @@ function hook_tokens($type, $tokens, array $data = array(), array $options = arr
break;
case 'created':
- $replacements[$original] = format_date($node->created, 'medium', '', NULL, $language_code);
+ $replacements[$original] = format_date($node->created, 'medium', '', NULL, $langcode);
break;
}
}
@@ -3827,12 +3827,12 @@ function hook_tokens($type, $tokens, array $data = array(), array $options = arr
function hook_tokens_alter(array &$replacements, array $context) {
$options = $context['options'];
- if (isset($options['language'])) {
- $url_options['language'] = $options['language'];
- $language_code = $options['language']->langcode;
+ if (isset($options['langcode'])) {
+ $url_options['language'] = language_load($options['langcode']);
+ $langcode = $options['langcode'];
}
else {
- $language_code = NULL;
+ $langcode = NULL;
}
$sanitize = !empty($options['sanitize']);
@@ -3842,7 +3842,7 @@ function hook_tokens_alter(array &$replacements, array $context) {
// Alter the [node:title] token, and replace it with the rendered content
// of a field (field_title).
if (isset($context['tokens']['title'])) {
- $title = field_view_field('node', $node, 'field_title', 'default', $language_code);
+ $title = field_view_field('node', $node, 'field_title', 'default', $langcode);
$replacements[$context['tokens']['title']] = drupal_render($title);
}
}
diff --git a/core/modules/system/system.tokens.inc b/core/modules/system/system.tokens.inc
index f9476fd..a5e7ad2 100644
--- a/core/modules/system/system.tokens.inc
+++ b/core/modules/system/system.tokens.inc
@@ -130,12 +130,12 @@ function system_token_info() {
*/
function system_tokens($type, $tokens, array $data = array(), array $options = array()) {
$url_options = array('absolute' => TRUE);
- if (isset($options['language'])) {
- $url_options['language'] = $options['language'];
- $language_code = $options['language']->langcode;
+ if (isset($options['langcode'])) {
+ $url_options['language'] = language_load($options['langcode']);
+ $langcode = $options['langcode'];
}
else {
- $language_code = NULL;
+ $langcode = NULL;
}
$sanitize = !empty($options['sanitize']);
@@ -184,19 +184,19 @@ function system_tokens($type, $tokens, array $data = array(), array $options = a
foreach ($tokens as $name => $original) {
switch ($name) {
case 'short':
- $replacements[$original] = format_date($date, 'short', '', NULL, $language_code);
+ $replacements[$original] = format_date($date, 'short', '', NULL, $langcode);
break;
case 'medium':
- $replacements[$original] = format_date($date, 'medium', '', NULL, $language_code);
+ $replacements[$original] = format_date($date, 'medium', '', NULL, $langcode);
break;
case 'long':
- $replacements[$original] = format_date($date, 'long', '', NULL, $language_code);
+ $replacements[$original] = format_date($date, 'long', '', NULL, $langcode);
break;
case 'since':
- $replacements[$original] = format_interval((REQUEST_TIME - $date), 2, $language_code);
+ $replacements[$original] = format_interval((REQUEST_TIME - $date), 2, $langcode);
break;
case 'raw':
@@ -207,7 +207,7 @@ function system_tokens($type, $tokens, array $data = array(), array $options = a
if ($created_tokens = token_find_with_prefix($tokens, 'custom')) {
foreach ($created_tokens as $name => $original) {
- $replacements[$original] = format_date($date, 'custom', $name, NULL, $language_code);
+ $replacements[$original] = format_date($date, 'custom', $name, NULL, $langcode);
}
}
}
@@ -245,7 +245,7 @@ function system_tokens($type, $tokens, array $data = array(), array $options = a
// These tokens are default variations on the chained tokens handled below.
case 'timestamp':
- $replacements[$original] = format_date($file->timestamp, 'medium', '', NULL, $language_code);
+ $replacements[$original] = format_date($file->timestamp, 'medium', '', NULL, $langcode);
break;
case 'owner':
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php
index 4f882ca..e273c1b 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php
@@ -91,7 +91,7 @@ class TokenReplaceTest extends TaxonomyTestBase {
$tests['[term:vocabulary:name]'] = check_plain($this->vocabulary->name);
foreach ($tests as $input => $expected) {
- $output = token_replace($input, array('term' => $term1), array('language' => $language_interface));
+ $output = token_replace($input, array('term' => $term1), array('langcode' => $language_interface->langcode));
$this->assertEqual($output, $expected, format_string('Sanitized taxonomy term token %token replaced.', array('%token' => $input)));
}
@@ -111,7 +111,7 @@ class TokenReplaceTest extends TaxonomyTestBase {
$this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
foreach ($tests as $input => $expected) {
- $output = token_replace($input, array('term' => $term2), array('language' => $language_interface));
+ $output = token_replace($input, array('term' => $term2), array('langcode' => $language_interface->langcode));
$this->assertEqual($output, $expected, format_string('Sanitized taxonomy term token %token replaced.', array('%token' => $input)));
}
@@ -122,7 +122,7 @@ class TokenReplaceTest extends TaxonomyTestBase {
$tests['[term:vocabulary:name]'] = $this->vocabulary->name;
foreach ($tests as $input => $expected) {
- $output = token_replace($input, array('term' => $term2), array('language' => $language_interface, 'sanitize' => FALSE));
+ $output = token_replace($input, array('term' => $term2), array('langcode' => $language_interface->langcode, 'sanitize' => FALSE));
$this->assertEqual($output, $expected, format_string('Unsanitized taxonomy term token %token replaced.', array('%token' => $input)));
}
@@ -138,7 +138,7 @@ class TokenReplaceTest extends TaxonomyTestBase {
$this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
foreach ($tests as $input => $expected) {
- $output = token_replace($input, array('vocabulary' => $this->vocabulary), array('language' => $language_interface));
+ $output = token_replace($input, array('vocabulary' => $this->vocabulary), array('langcode' => $language_interface->langcode));
$this->assertEqual($output, $expected, format_string('Sanitized taxonomy vocabulary token %token replaced.', array('%token' => $input)));
}
@@ -147,7 +147,7 @@ class TokenReplaceTest extends TaxonomyTestBase {
$tests['[vocabulary:description]'] = $this->vocabulary->description;
foreach ($tests as $input => $expected) {
- $output = token_replace($input, array('vocabulary' => $this->vocabulary), array('language' => $language_interface, 'sanitize' => FALSE));
+ $output = token_replace($input, array('vocabulary' => $this->vocabulary), array('langcode' => $language_interface->langcode, 'sanitize' => FALSE));
$this->assertEqual($output, $expected, format_string('Unsanitized taxonomy vocabulary token %token replaced.', array('%token' => $input)));
}
}
diff --git a/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php b/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php
index a409150..d2ff1e9 100644
--- a/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php
+++ b/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php
@@ -274,31 +274,31 @@ class TranslationTest extends WebTestBase {
/**
* Installs the specified language, or enables it if it is already installed.
*
- * @param $language_code
+ * @param $langcode
* The language code to check.
*/
- function addLanguage($language_code) {
+ function addLanguage($langcode) {
// Check to make sure that language has not already been installed.
$this->drupalGet('admin/config/regional/language');
- if (strpos($this->drupalGetContent(), 'languages[' . $language_code . ']') === FALSE) {
+ if (strpos($this->drupalGetContent(), 'languages[' . $langcode . ']') === FALSE) {
// Doesn't have language installed so add it.
$edit = array();
- $edit['predefined_langcode'] = $language_code;
+ $edit['predefined_langcode'] = $langcode;
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
// Make sure we are not using a stale list.
drupal_static_reset('language_list');
$languages = language_list();
- $this->assertTrue(array_key_exists($language_code, $languages), t('Language was installed successfully.'));
+ $this->assertTrue(array_key_exists($langcode, $languages), t('Language was installed successfully.'));
- if (array_key_exists($language_code, $languages)) {
- $this->assertRaw(t('The language %language has been created and can now be used.', array('%language' => $languages[$language_code]->name)), t('Language has been created.'));
+ if (array_key_exists($langcode, $languages)) {
+ $this->assertRaw(t('The language %language has been created and can now be used.', array('%language' => $languages[$langcode]->name)), t('Language has been created.'));
}
}
else {
// It's installed. No need to do anything.
- $this->assertTrue(true, 'Language [' . $language_code . '] already installed.');
+ $this->assertTrue(true, 'Language [' . $langcode . '] already installed.');
}
}
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php b/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php
index 16427bf..3daa476 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php
@@ -75,7 +75,7 @@ class UserTokenReplaceTest extends WebTestBase {
$this->assertFalse(in_array(0, array_map('strlen', $tests)), t('No empty tokens generated.'));
foreach ($tests as $input => $expected) {
- $output = token_replace($input, array('user' => $account), array('language' => $language_interface));
+ $output = token_replace($input, array('user' => $account), array('langcode' => $language_interface->langcode));
$this->assertEqual($output, $expected, t('Sanitized user token %token replaced.', array('%token' => $input)));
}
@@ -85,7 +85,7 @@ class UserTokenReplaceTest extends WebTestBase {
$tests['[current-user:name]'] = user_format_name($global_account);
foreach ($tests as $input => $expected) {
- $output = token_replace($input, array('user' => $account), array('language' => $language_interface, 'sanitize' => FALSE));
+ $output = token_replace($input, array('user' => $account), array('langcode' => $language_interface->langcode, 'sanitize' => FALSE));
$this->assertEqual($output, $expected, t('Unsanitized user token %token replaced.', array('%token' => $input)));
}
diff --git a/core/modules/user/user.tokens.inc b/core/modules/user/user.tokens.inc
index 833e763..bc37434 100644
--- a/core/modules/user/user.tokens.inc
+++ b/core/modules/user/user.tokens.inc
@@ -63,9 +63,9 @@ function user_token_info() {
*/
function user_tokens($type, $tokens, array $data = array(), array $options = array()) {
$url_options = array('absolute' => TRUE);
- if (isset($options['language'])) {
- $url_options['language'] = $options['language'];
- $langcode = $options['language']->langcode;
+ if (isset($options['langcode'])) {
+ $url_options['language'] = language_load($options['langcode']);
+ $langcode = $options['langcode'];
}
else {
$langcode = NULL;