diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc index d37a98e..1905b7e 100644 --- a/includes/bootstrap.inc +++ b/includes/bootstrap.inc @@ -1247,7 +1247,7 @@ function drupal_unpack($obj, $field = 'data') { * drupal_placeholder(), which shows up as emphasized text. * @param $options * An associative array of additional options, with the following elements: - * - 'langcode' (defaults to the current language): The language code to + * - 'locale' (defaults to the current language): The language code to * translate to a language other than what is used to display the page. * - 'context' (defaults to the empty context): The context the source string * belongs to. @@ -1264,8 +1264,8 @@ function t($string, array $args = array(), array $options = array()) { static $custom_strings; // Merge in default. - if (empty($options['langcode'])) { - $options['langcode'] = isset($language->language) ? $language->language : 'en'; + if (empty($options['locale'])) { + $options['locale'] = isset($language->language) ? $language->language : 'en'; } if (empty($options['context'])) { $options['context'] = ''; @@ -1275,16 +1275,16 @@ function t($string, array $args = array(), array $options = array()) { // *instead of* database lookups. This is a high performance way to provide a // handful of string replacements. See settings.php for examples. // Cache the $custom_strings variable to improve performance. - if (!isset($custom_strings[$options['langcode']])) { - $custom_strings[$options['langcode']] = variable_get('locale_custom_strings_' . $options['langcode'], array()); + if (!isset($custom_strings[$options['locale']])) { + $custom_strings[$options['locale']] = variable_get('locale_custom_strings_' . $options['locale'], array()); } // Custom strings work for English too, even if locale module is disabled. - if (isset($custom_strings[$options['langcode']][$options['context']][$string])) { - $string = $custom_strings[$options['langcode']][$options['context']][$string]; + if (isset($custom_strings[$options['locale']][$options['context']][$string])) { + $string = $custom_strings[$options['locale']][$options['context']][$string]; } // Translate with locale module if enabled. - elseif ($options['langcode'] != 'en' && function_exists('locale')) { - $string = locale($string, $options['context'], $options['langcode']); + elseif ($options['locale'] != 'en' && function_exists('locale')) { + $string = locale($string, $options['context'], $options['locale']); } if (empty($args)) { return $string; diff --git a/includes/common.inc b/includes/common.inc index d7189ab..1f13251 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -1578,9 +1578,9 @@ function filter_xss_bad_protocol($string, $decode = TRUE) { * * Arbitrary elements may be added using the $args associative array. */ -function format_rss_channel($title, $link, $description, $items, $langcode = NULL, $args = array()) { +function format_rss_channel($title, $link, $description, $items, $locale = NULL, $args = array()) { global $language_content; - $langcode = $langcode ? $langcode : $language_content->language; + $locale = $locale ? $locale : $language_content->language; $output = "\n"; $output .= ' ' . check_plain($title) . "\n"; @@ -1590,7 +1590,7 @@ function format_rss_channel($title, $link, $description, $items, $langcode = NUL // We strip all HTML tags, but need to prevent double encoding from properly // escaped source data (such as & becoming &amp;). $output .= ' ' . check_plain(decode_entities(strip_tags($description))) . "\n"; - $output .= ' ' . check_plain($langcode) . "\n"; + $output .= ' ' . check_plain($locale) . "\n"; $output .= format_xml_elements($args); $output .= $items; $output .= "\n"; @@ -1695,7 +1695,7 @@ function format_xml_elements($array) { * This replacement is done automatically for the plural case. * @param $options * An associative array of additional options, with the following keys: - * - 'langcode' (default to the current language) The language code to + * - 'locale' (default to the current language) The language code to * translate to a language other than what is used to display the page. * - 'context' (default to the empty context) The context the source string * belongs to. @@ -1709,7 +1709,7 @@ function format_plural($count, $singular, $plural, array $args = array(), array } // Get the plural index through the gettext formula. - $index = (function_exists('locale_get_plural')) ? locale_get_plural($count, isset($options['langcode']) ? $options['langcode'] : NULL) : -1; + $index = (function_exists('locale_get_plural')) ? locale_get_plural($count, isset($options['locale']) ? $options['locale'] : NULL) : -1; // Backwards compatibility. if ($index < 0) { return t($plural, $args, $options); @@ -1754,27 +1754,27 @@ function parse_size($size) { * * @param $size * A size in bytes. - * @param $langcode + * @param $locale * Optional language code to translate to a language other than what is used * to display the page. * @return * A translated string representation of the size. */ -function format_size($size, $langcode = NULL) { +function format_size($size, $locale = NULL) { if ($size < DRUPAL_KILOBYTE) { - return format_plural($size, '1 byte', '@count bytes', array(), array('langcode' => $langcode)); + return format_plural($size, '1 byte', '@count bytes', array(), array('locale' => $locale)); } else { $size = $size / DRUPAL_KILOBYTE; // Convert bytes to kilobytes. $units = array( - t('@size KB', array(), array('langcode' => $langcode)), - t('@size MB', array(), array('langcode' => $langcode)), - t('@size GB', array(), array('langcode' => $langcode)), - t('@size TB', array(), array('langcode' => $langcode)), - t('@size PB', array(), array('langcode' => $langcode)), - t('@size EB', array(), array('langcode' => $langcode)), - t('@size ZB', array(), array('langcode' => $langcode)), - t('@size YB', array(), array('langcode' => $langcode)), + t('@size KB', array(), array('locale' => $locale)), + t('@size MB', array(), array('locale' => $locale)), + t('@size GB', array(), array('locale' => $locale)), + t('@size TB', array(), array('locale' => $locale)), + t('@size PB', array(), array('locale' => $locale)), + t('@size EB', array(), array('locale' => $locale)), + t('@size ZB', array(), array('locale' => $locale)), + t('@size YB', array(), array('locale' => $locale)), ); foreach ($units as $unit) { if (round($size, 2) >= DRUPAL_KILOBYTE) { @@ -1795,13 +1795,13 @@ function format_size($size, $langcode = NULL) { * The length of the interval in seconds. * @param $granularity * How many different units to display in the string. - * @param $langcode + * @param $locale * Optional language code to translate to a language other than * what is used to display the page. * @return * A translated string representation of the interval. */ -function format_interval($timestamp, $granularity = 2, $langcode = NULL) { +function format_interval($timestamp, $granularity = 2, $locale = NULL) { $units = array( '1 year|@count years' => 31536000, '1 month|@count months' => 2592000, @@ -1815,7 +1815,7 @@ function format_interval($timestamp, $granularity = 2, $langcode = NULL) { foreach ($units as $key => $value) { $key = explode('|', $key); if ($timestamp >= $value) { - $output .= ($output ? ' ' : '') . format_plural(floor($timestamp / $value), $key[0], $key[1], array(), array('langcode' => $langcode)); + $output .= ($output ? ' ' : '') . format_plural(floor($timestamp / $value), $key[0], $key[1], array(), array('locale' => $locale)); $timestamp %= $value; $granularity--; } @@ -1824,7 +1824,7 @@ function format_interval($timestamp, $granularity = 2, $langcode = NULL) { break; } } - return $output ? $output : t('0 sec', array(), array('langcode' => $langcode)); + return $output ? $output : t('0 sec', array(), array('locale' => $locale)); } /** @@ -1848,14 +1848,14 @@ function format_interval($timestamp, $granularity = 2, $langcode = NULL) { * (optional) Time zone identifier, as described at * http://php.net/manual/en/timezones.php Defaults to the time zone used to * display the page. - * @param $langcode + * @param $locale * (optional) Language code to translate to. Defaults to the language used to * display the page. * * @return * A translated date string in the requested format. */ -function format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) { +function format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $locale = NULL) { // Use the advanced drupal_static() pattern, since this is called very often. static $drupal_static_fast; if (!isset($drupal_static_fast)) { @@ -1872,10 +1872,10 @@ function format_date($timestamp, $type = 'medium', $format = '', $timezone = NUL $timezones[$timezone] = timezone_open($timezone); } - // Use the default langcode if none is set. + // Use the default locale if none is set. global $language; - if (empty($langcode)) { - $langcode = isset($language->language) ? $language->language : 'en'; + if (empty($locale)) { + $locale = isset($language->language) ? $language->language : 'en'; } switch ($type) { @@ -1919,8 +1919,8 @@ function format_date($timestamp, $type = 'medium', $format = '', $timezone = NUL // Call date_format(). $format = date_format($date_time, $format); - // Pass the langcode to _format_date_callback(). - _format_date_callback(NULL, $langcode); + // Pass the locale to _format_date_callback(). + _format_date_callback(NULL, $locale); // Translate the marked sequences. return preg_replace_callback('/\xEF([AaeDlMTF]?)(.*?)\xFF/', '_format_date_callback', $format); @@ -1945,21 +1945,21 @@ function date_iso8601($date) { /** * Callback function for preg_replace_callback(). */ -function _format_date_callback(array $matches = NULL, $new_langcode = NULL) { +function _format_date_callback(array $matches = NULL, $new_locale = NULL) { // We cache translations to avoid redundant and rather costly calls to t(). - static $cache, $langcode; + static $cache, $locale; if (!isset($matches)) { - $langcode = $new_langcode; + $locale = $new_locale; return; } $code = $matches[1]; $string = $matches[2]; - if (!isset($cache[$langcode][$code][$string])) { + if (!isset($cache[$locale][$code][$string])) { $options = array( - 'langcode' => $langcode, + 'locale' => $locale, ); if ($code == 'F') { @@ -1967,13 +1967,13 @@ function _format_date_callback(array $matches = NULL, $new_langcode = NULL) { } if ($code == '') { - $cache[$langcode][$code][$string] = $string; + $cache[$locale][$code][$string] = $string; } else { - $cache[$langcode][$code][$string] = t($string, array(), $options); + $cache[$locale][$code][$string] = t($string, array(), $options); } } - return $cache[$langcode][$code][$string]; + return $cache[$locale][$code][$string]; } /** @@ -7289,10 +7289,10 @@ function entity_get_info($entity_type = NULL) { // hook_entity_info() includes translated strings, so each language is cached // separately. - $langcode = $language->language; + $locale = $language->language; if (empty($entity_info)) { - if ($cache = cache_get("entity_info:$langcode")) { + if ($cache = cache_get("entity_info:$locale")) { $entity_info = $cache->data; } else { @@ -7335,7 +7335,7 @@ function entity_get_info($entity_type = NULL) { } // Let other modules alter the entity info. drupal_alter('entity_info', $entity_info); - cache_set("entity_info:$langcode", $entity_info); + cache_set("entity_info:$locale", $entity_info); } } @@ -7509,13 +7509,13 @@ function entity_get_controller($entity_type) { * The type of entity, i.e. 'node', 'user'. * @param $entities * The entity objects which are being prepared for view, keyed by object ID. - * @param $langcode + * @param $locale * (optional) A language code to be used for rendering. Defaults to the global * content language of the current request. */ -function entity_prepare_view($entity_type, $entities, $langcode = NULL) { - if (!isset($langcode)) { - $langcode = $GLOBALS['language_content']->language; +function entity_prepare_view($entity_type, $entities, $locale = NULL) { + if (!isset($locale)) { + $locale = $GLOBALS['language_content']->language; } // To ensure hooks are only run once per entity, check for an @@ -7533,7 +7533,7 @@ function entity_prepare_view($entity_type, $entities, $langcode = NULL) { } if (!empty($prepare)) { - module_invoke_all('entity_prepare_view', $prepare, $entity_type, $langcode); + module_invoke_all('entity_prepare_view', $prepare, $entity_type, $locale); } } diff --git a/includes/install.core.inc b/includes/install.core.inc index a74dfdf..eae0c02 100644 --- a/includes/install.core.inc +++ b/includes/install.core.inc @@ -1121,10 +1121,10 @@ function install_find_locales($profilename) { array_unshift($locales, (object) array('name' => 'en')); foreach ($locales as $key => $locale) { // The locale (file name) might be drupal-7.2.cs.po instead of cs.po. - $locales[$key]->langcode = preg_replace('!^(.+\.)?([^\.]+)$!', '\2', $locale->name); + $locales[$key]->locale = preg_replace('!^(.+\.)?([^\.]+)$!', '\2', $locale->name); // Language codes cannot exceed 12 characters to fit into the {languages} // table. - if (strlen($locales[$key]->langcode) > 12) { + if (strlen($locales[$key]->locale) > 12) { unset($locales[$key]); } } @@ -1153,8 +1153,8 @@ function install_select_locale(&$install_state) { if (!empty($_POST['locale'])) { foreach ($locales as $locale) { - if ($_POST['locale'] == $locale->langcode) { - $install_state['parameters']['locale'] = $locale->langcode; + if ($_POST['locale'] == $locale->locale) { + $install_state['parameters']['locale'] = $locale->locale; return; } } @@ -1237,15 +1237,15 @@ function install_select_locale_form($form, &$form_state, $locales, $profilename) include_once DRUPAL_ROOT . '/includes/iso.inc'; $languages = _locale_get_predefined_list(); foreach ($locales as $locale) { - $name = $locale->langcode; + $name = $locale->locale; if (isset($languages[$name])) { $name = $languages[$name][0] . (isset($languages[$name][1]) ? ' ' . st('(@language)', array('@language' => $languages[$name][1])) : ''); } - $form['locale'][$locale->langcode] = array( + $form['locale'][$locale->locale] = array( '#type' => 'radio', - '#return_value' => $locale->langcode, - '#default_value' => $locale->langcode == 'en' ? 'en' : '', - '#title' => $name . ($locale->langcode == 'en' ? ' ' . st('(built-in)') : ''), + '#return_value' => $locale->locale, + '#default_value' => $locale->locale == 'en' ? 'en' : '', + '#title' => $name . ($locale->locale == 'en' ? ' ' . st('(built-in)') : ''), '#parents' => array('locale') ); } diff --git a/includes/language.inc b/includes/language.inc index b7057f2..60a8e23 100644 --- a/includes/language.inc +++ b/includes/language.inc @@ -345,8 +345,8 @@ function language_provider_invoke($provider_id, $provider = NULL) { // we can execute the callback. $cache = !isset($provider['cache']) || $user->uid || $provider['cache'] == variable_get('cache', 0); $callback = isset($provider['callbacks']['language']) ? $provider['callbacks']['language'] : FALSE; - $langcode = $cache && function_exists($callback) ? $callback($languages) : FALSE; - $results[$provider_id] = isset($languages[$langcode]) ? $languages[$langcode] : FALSE; + $locale = $cache && function_exists($callback) ? $callback($languages) : FALSE; + $results[$provider_id] = isset($languages[$locale]) ? $languages[$locale] : FALSE; } return $results[$provider_id]; diff --git a/includes/locale.inc b/includes/locale.inc index 6154cf3..cb78918 100644 --- a/includes/locale.inc +++ b/includes/locale.inc @@ -119,9 +119,9 @@ function locale_language_from_browser($languages) { arsort($browser_langs); // Try to find the first preferred language we have - foreach ($browser_langs as $langcode => $q) { - if (isset($languages[$langcode])) { - return $langcode; + foreach ($browser_langs as $locale => $q) { + if (isset($languages[$locale])) { + return $locale; } } @@ -163,12 +163,12 @@ function locale_language_from_session($languages) { // Request parameter: we need to update the session parameter only if we have // an authenticated user. - if (isset($_GET[$param]) && isset($languages[$langcode = $_GET[$param]])) { + if (isset($_GET[$param]) && isset($languages[$locale = $_GET[$param]])) { global $user; if ($user->uid) { - $_SESSION[$param] = $langcode; + $_SESSION[$param] = $locale; } - return $langcode; + return $locale; } // Session parameter. @@ -302,18 +302,18 @@ function locale_language_switcher_session($type, $path) { unset($query['q']); foreach ($languages[1] as $language) { - $langcode = $language->language; - $links[$langcode] = array( + $locale = $language->language; + $links[$locale] = array( 'href' => $path, 'title' => $language->native, 'attributes' => array('class' => array('language-link')), 'query' => $query, ); - if ($language_query != $langcode) { - $links[$langcode]['query'][$param] = $langcode; + if ($language_query != $locale) { + $links[$locale]['query'][$param] = $locale; } else { - $links[$langcode]['attributes']['class'][] = ' session-active'; + $links[$locale]['attributes']['class'][] = ' session-active'; } } @@ -433,7 +433,7 @@ function locale_string_is_safe($string) { /** * API function to add a language. * - * @param $langcode + * @param $locale * Language code. * @param $name * English name of the language @@ -452,24 +452,24 @@ function locale_string_is_safe($string) { * @param $default * Optionally set this language to be the default. */ -function locale_add_language($langcode, $name = NULL, $native = NULL, $direction = LANGUAGE_LTR, $domain = '', $prefix = '', $enabled = TRUE, $default = FALSE) { +function locale_add_language($locale, $name = NULL, $native = NULL, $direction = LANGUAGE_LTR, $domain = '', $prefix = '', $enabled = TRUE, $default = FALSE) { // Default prefix on language code. if (empty($prefix)) { - $prefix = $langcode; + $prefix = $locale; } // If name was not set, we add a predefined language. if (!isset($name)) { include_once DRUPAL_ROOT . '/includes/iso.inc'; $predefined = _locale_get_predefined_list(); - $name = $predefined[$langcode][0]; - $native = isset($predefined[$langcode][1]) ? $predefined[$langcode][1] : $predefined[$langcode][0]; - $direction = isset($predefined[$langcode][2]) ? $predefined[$langcode][2] : LANGUAGE_LTR; + $name = $predefined[$locale][0]; + $native = isset($predefined[$locale][1]) ? $predefined[$locale][1] : $predefined[$locale][0]; + $direction = isset($predefined[$locale][2]) ? $predefined[$locale][2] : LANGUAGE_LTR; } db_insert('languages') ->fields(array( - 'language' => $langcode, + 'language' => $locale, 'name' => $name, 'native' => $native, 'direction' => $direction, @@ -481,7 +481,7 @@ function locale_add_language($langcode, $name = NULL, $native = NULL, $direction // Only set it as default if enabled. if ($enabled && $default) { - variable_set('language_default', (object) array('language' => $langcode, 'name' => $name, 'native' => $native, 'direction' => $direction, 'enabled' => (int) $enabled, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => $prefix, 'weight' => 0, 'javascript' => '')); + variable_set('language_default', (object) array('language' => $locale, 'name' => $name, 'native' => $native, 'direction' => $direction, 'enabled' => (int) $enabled, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => $prefix, 'weight' => 0, 'javascript' => '')); } if ($enabled) { @@ -493,9 +493,9 @@ function locale_add_language($langcode, $name = NULL, $native = NULL, $direction drupal_static_reset('language_list'); // Force JavaScript translation file creation for the newly added language. - _locale_invalidate_js($langcode); + _locale_invalidate_js($locale); - watchdog('locale', 'The %language language (%code) has been created.', array('%language' => $name, '%code' => $langcode)); + watchdog('locale', 'The %language language (%code) has been created.', array('%language' => $name, '%code' => $locale)); module_invoke_all('multilingual_settings_changed'); } @@ -517,7 +517,7 @@ function locale_add_language($langcode, $name = NULL, $native = NULL, $direction * * @param $file * Drupal file object corresponding to the PO file to import. - * @param $langcode + * @param $locale * Language code. * @param $mode * Should existing translations be replaced LOCALE_IMPORT_KEEP or @@ -526,18 +526,18 @@ function locale_add_language($langcode, $name = NULL, $native = NULL, $direction * Text group to import PO file into (eg. 'default' for interface * translations). */ -function _locale_import_po($file, $langcode, $mode, $group = NULL) { +function _locale_import_po($file, $locale, $mode, $group = NULL) { // Try to allocate enough time to parse and import the data. drupal_set_time_limit(240); // Check if we have the language already in the database. - if (!db_query("SELECT COUNT(language) FROM {languages} WHERE language = :language", array(':language' => $langcode))->fetchField()) { + if (!db_query("SELECT COUNT(language) FROM {languages} WHERE language = :language", array(':language' => $locale))->fetchField()) { drupal_set_message(t('The language selected for import is not supported.'), 'error'); return FALSE; } // Get strings from file (returns on failure after a partial import, or on success) - $status = _locale_import_read_po('db-store', $file, $mode, $langcode, $group); + $status = _locale_import_read_po('db-store', $file, $mode, $locale, $group); if ($status === FALSE) { // Error messages are set in _locale_import_read_po(). return FALSE; @@ -551,14 +551,14 @@ function _locale_import_po($file, $langcode, $mode, $group = NULL) { } // Clear cache and force refresh of JavaScript translations. - _locale_invalidate_js($langcode); + _locale_invalidate_js($locale); cache_clear_all('locale:', 'cache', TRUE); // Rebuild the menu, strings may have changed. menu_rebuild(); drupal_set_message(t('The translation was successfully imported. There are %number newly created translated strings, %update strings were updated and %delete strings were removed.', array('%number' => $additions, '%update' => $updates, '%delete' => $deletes))); - watchdog('locale', 'Imported %file into %locale: %number new strings added, %update updated and %delete removed.', array('%file' => $file->filename, '%locale' => $langcode, '%number' => $additions, '%update' => $updates, '%delete' => $deletes)); + watchdog('locale', 'Imported %file into %locale: %number new strings added, %update updated and %delete removed.', array('%file' => $file->filename, '%locale' => $locale, '%number' => $additions, '%update' => $updates, '%delete' => $deletes)); if ($skips) { $skip_message = format_plural($skips, 'One translation string was skipped because it contains disallowed HTML.', '@count translation strings were skipped because they contain disallowed HTML.'); drupal_set_message($skip_message); @@ -960,14 +960,14 @@ function _locale_import_one_string($op, $value = NULL, $mode = NULL, $lang = NUL * @param $report * Report array summarizing the number of changes done in the form: * array(inserts, updates, deletes). - * @param $langcode + * @param $locale * Language code to import string into. * @param $context * The context of this string. * @param $source * Source string. * @param $translation - * Translation to language specified in $langcode. + * Translation to language specified in $locale. * @param $textgroup * Name of textgroup to store translation in. * @param $location @@ -982,7 +982,7 @@ function _locale_import_one_string($op, $value = NULL, $mode = NULL, $lang = NUL * @return * The string ID of the existing string modified or the new string added. */ -function _locale_import_one_string_db(&$report, $langcode, $context, $source, $translation, $textgroup, $location, $mode, $plid = 0, $plural = 0) { +function _locale_import_one_string_db(&$report, $locale, $context, $source, $translation, $textgroup, $location, $mode, $plid = 0, $plural = 0) { $lid = db_query("SELECT lid FROM {locales_source} WHERE source = :source AND context = :context AND textgroup = :textgroup", array(':source' => $source, ':context' => $context, ':textgroup' => $textgroup))->fetchField(); if (!empty($translation)) { @@ -1002,14 +1002,14 @@ function _locale_import_one_string_db(&$report, $langcode, $context, $source, $t ->condition('lid', $lid) ->execute(); - $exists = db_query("SELECT COUNT(lid) FROM {locales_target} WHERE lid = :lid AND language = :language", array(':lid' => $lid, ':language' => $langcode))->fetchField(); + $exists = db_query("SELECT COUNT(lid) FROM {locales_target} WHERE lid = :lid AND language = :language", array(':lid' => $lid, ':language' => $locale))->fetchField(); if (!$exists) { // No translation in this language. db_insert('locales_target') ->fields(array( 'lid' => $lid, - 'language' => $langcode, + 'language' => $locale, 'translation' => $translation, 'plid' => $plid, 'plural' => $plural, @@ -1026,7 +1026,7 @@ function _locale_import_one_string_db(&$report, $langcode, $context, $source, $t 'plid' => $plid, 'plural' => $plural, )) - ->condition('language', $langcode) + ->condition('language', $locale) ->condition('lid', $lid) ->execute(); @@ -1047,7 +1047,7 @@ function _locale_import_one_string_db(&$report, $langcode, $context, $source, $t db_insert('locales_target') ->fields(array( 'lid' => $lid, - 'language' => $langcode, + 'language' => $locale, 'translation' => $translation, 'plid' => $plid, 'plural' => $plural @@ -1060,7 +1060,7 @@ function _locale_import_one_string_db(&$report, $langcode, $context, $source, $t elseif ($mode == LOCALE_IMPORT_OVERWRITE) { // Empty translation, remove existing if instructed. db_delete('locales_target') - ->condition('language', $langcode) + ->condition('language', $locale) ->condition('lid', $lid) ->condition('plid', $plid) ->condition('plural', $plural) @@ -1819,16 +1819,16 @@ function _locale_translate_seek_query() { * files are rebuilt (with locale_update_js_files()) the next time a * request is served in that language. * - * @param $langcode + * @param $locale * The language code for which the file needs to be refreshed. * * @return * New content of the 'javascript_parsed' variable. */ -function _locale_invalidate_js($langcode = NULL) { +function _locale_invalidate_js($locale = NULL) { $parsed = variable_get('javascript_parsed', array()); - if (empty($langcode)) { + if (empty($locale)) { // Invalidate all languages. $languages = language_list(); unset($languages['en']); @@ -1838,7 +1838,7 @@ function _locale_invalidate_js($langcode = NULL) { } else { // Invalidate single language. - $parsed['refresh:' . $langcode] = 'waiting'; + $parsed['refresh:' . $locale] = 'waiting'; } variable_set('javascript_parsed', $parsed); @@ -1851,14 +1851,14 @@ function _locale_invalidate_js($langcode = NULL) { * @param $language * The language, the translation file should be (re)created for. */ -function _locale_rebuild_js($langcode = NULL) { - if (!isset($langcode)) { +function _locale_rebuild_js($locale = NULL) { + if (!isset($locale)) { global $language; } else { // Get information about the locale. $languages = language_list(); - $language = $languages[$langcode]; + $language = $languages[$locale]; } // Construct the array for JavaScript translations. @@ -1943,9 +1943,9 @@ function _locale_rebuild_js($langcode = NULL) { // Update the default language variable if the default language has been altered. // This is necessary to keep the variable consistent with the database // version of the language and to prevent checking against an outdated hash. - $default_langcode = language_default('language'); - if ($default_langcode == $language->language) { - $default = db_query("SELECT * FROM {languages} WHERE language = :language", array(':language' => $default_langcode))->fetchObject(); + $default_locale = language_default('language'); + if ($default_locale == $language->language) { + $default = db_query("SELECT * FROM {languages} WHERE language = :language", array(':language' => $default_locale))->fetchObject(); variable_set('language_default', $default); } } @@ -1984,9 +1984,9 @@ function _locale_translate_language_list($translation, $limit_language) { $languages = language_list(); unset($languages['en']); $output = ''; - foreach ($languages as $langcode => $language) { - if (!$limit_language || $limit_language == $langcode) { - $output .= (!empty($translation[$langcode])) ? $langcode . ' ' : "$langcode "; + foreach ($languages as $locale => $language) { + if (!$limit_language || $limit_language == $locale) { + $output .= (!empty($translation[$locale])) ? $locale . ' ' : "$locale "; } } @@ -2044,7 +2044,7 @@ function _locale_prepare_predefined_list() { * Prepare a batch to import translations for all enabled * modules in a given language. * - * @param $langcode + * @param $locale * Language code to import translations for. * @param $finished * Optional finished callback for the batch. @@ -2055,7 +2055,7 @@ function _locale_prepare_predefined_list() { * @return * A batch structure or FALSE if no files found. */ -function locale_batch_by_language($langcode, $finished = NULL, $skip = array()) { +function locale_batch_by_language($locale, $finished = NULL, $skip = array()) { // Collect all files to import for all enabled modules and themes. $files = array(); $components = array(); @@ -2067,11 +2067,11 @@ function locale_batch_by_language($langcode, $finished = NULL, $skip = array()) } $result = $query->execute(); foreach ($result as $component) { - // Collect all files for all components, names as $langcode.po or - // with names ending with $langcode.po. This allows for filenames + // Collect all files for all components, names as $locale.po or + // with names ending with $locale.po. This allows for filenames // like node-module.de.po to let translators use small files and // be able to import in smaller chunks. - $files = array_merge($files, file_scan_directory(dirname($component->filename) . '/translations', '/(^|\.)' . $langcode . '\.po$/', array('recurse' => FALSE))); + $files = array_merge($files, file_scan_directory(dirname($component->filename) . '/translations', '/(^|\.)' . $locale . '\.po$/', array('recurse' => FALSE))); $components[] = $component->name; } @@ -2101,7 +2101,7 @@ function locale_batch_by_component($components, $finished = '_locale_batch_syste foreach ($result as $component) { if (in_array($component->name, $components)) { // Collect all files for this component in all enabled languages, named - // as $langcode.po or with names ending with $langcode.po. This allows + // as $locale.po or with names ending with $locale.po. This allows // for filenames like node-module.de.po to let translators use small // files and be able to import in smaller chunks. $files = array_merge($files, file_scan_directory(dirname($component->filename) . '/translations', '/(^|\.)(' . $language_list . ')\.po$/', array('recurse' => FALSE))); @@ -2160,11 +2160,11 @@ function _locale_batch_build($files, $finished = NULL, $components = array()) { * Contains a list of files imported. */ function _locale_batch_import($filepath, &$context) { - // The filename is either {langcode}.po or {prefix}.{langcode}.po, so + // The filename is either {locale}.po or {prefix}.{locale}.po, so // we can extract the language code to use for the import from the end. - if (preg_match('!(/|\.)([^\./]+)\.po$!', $filepath, $langcode)) { + if (preg_match('!(/|\.)([^\./]+)\.po$!', $filepath, $locale)) { $file = (object) array('filename' => basename($filepath), 'uri' => $filepath); - _locale_import_read_po('db-store', $file, LOCALE_IMPORT_KEEP, $langcode[2]); + _locale_import_read_po('db-store', $file, LOCALE_IMPORT_KEEP, $locale[2]); $context['results'][] = $filepath; } } @@ -2210,7 +2210,7 @@ function country_get_list() { /** * Save locale specific date formats to the database. * - * @param $langcode + * @param $locale * Language code, can be 2 characters, e.g. 'en' or 5 characters, e.g. * 'en-CA'. * @param $type @@ -2218,13 +2218,13 @@ function country_get_list() { * @param $format * The date format string. */ -function locale_date_format_save($langcode, $type, $format) { +function locale_date_format_save($locale, $type, $format) { $locale_format = array(); - $locale_format['language'] = $langcode; + $locale_format['language'] = $locale; $locale_format['type'] = $type; $locale_format['format'] = $format; - $is_existing = (bool) db_query_range('SELECT 1 FROM {date_format_locale} WHERE language = :langcode AND type = :type', 0, 1, array(':langcode' => $langcode, ':type' => $type))->fetchField(); + $is_existing = (bool) db_query_range('SELECT 1 FROM {date_format_locale} WHERE language = :locale AND type = :type', 0, 1, array(':locale' => $locale, ':type' => $type))->fetchField(); if ($is_existing) { $keys = array('type', 'language'); drupal_write_record('date_format_locale', $locale_format, $keys); diff --git a/includes/mail.inc b/includes/mail.inc index 7272df9..2375f22 100644 --- a/includes/mail.inc +++ b/includes/mail.inc @@ -57,9 +57,9 @@ define('MAIL_LINE_ENDINGS', isset($_SERVER['WINDIR']) || strpos($_SERVER['SERVER * user_mail_tokens($variables, $data, $options); * switch($key) { * case 'notice': - * $langcode = $message['language']->language; - * $message['subject'] = t('Notification from !site', $variables, array('langcode' => $langcode)); - * $message['body'][] = t("Dear !username\n\nThere is new content available on the site.", $variables, array('langcode' => $langcode)); + * $locale = $message['language']->language; + * $message['subject'] = t('Notification from !site', $variables, array('locale' => $locale)); + * $message['body'][] = t("Dear !username\n\nThere is new content available on the site.", $variables, array('locale' => $locale)); * break; * } * } diff --git a/modules/aggregator/aggregator.test b/modules/aggregator/aggregator.test index 1ab12dc..9dc3604 100644 --- a/modules/aggregator/aggregator.test +++ b/modules/aggregator/aggregator.test @@ -267,12 +267,12 @@ EOF; } function createSampleNodes() { - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // Post 5 articles. for ($i = 0; $i < 5; $i++) { $edit = array(); $edit['title'] = $this->randomName(); - $edit["body[$langcode][0][value]"] = $this->randomName(); + $edit["body[$locale][0][value]"] = $this->randomName(); $this->drupalPost('node/add/article', $edit, t('Save')); } } diff --git a/modules/blog/blog.test b/modules/blog/blog.test index 6ff66a2..9aac007 100644 --- a/modules/blog/blog.test +++ b/modules/blog/blog.test @@ -162,9 +162,9 @@ class BlogTestCase extends DrupalWebTestCase { if ($response == 200) { // Edit blog node. $edit = array(); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $edit["title"] = 'node/' . $node->nid; - $edit["body[$langcode][0][value]"] = $this->randomName(256); + $edit["body[$locale][0][value]"] = $this->randomName(256); $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save')); $this->assertRaw(t('Blog entry %title has been updated.', array('%title' => $edit["title"])), t('Blog node was edited')); diff --git a/modules/book/book.admin.inc b/modules/book/book.admin.inc index 7b9dea3..e63a4b3 100644 --- a/modules/book/book.admin.inc +++ b/modules/book/book.admin.inc @@ -123,7 +123,7 @@ function book_admin_edit_submit($form, &$form_state) { // Update the title if changed. if ($row['title']['#default_value'] != $values['title']) { $node = node_load($values['nid']); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $node->title = $values['title']; $node->book['link_title'] = $values['title']; $node->revision = 1; diff --git a/modules/book/book.test b/modules/book/book.test index cc61778..4edf896 100644 --- a/modules/book/book.test +++ b/modules/book/book.test @@ -196,9 +196,9 @@ class BookTestCase extends DrupalWebTestCase { static $number = 0; // Used to ensure that when sorted nodes stay in same order. $edit = array(); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $edit["title"] = $number . ' - SimpleTest test node ' . $this->randomName(10); - $edit["body[$langcode][0][value]"] = 'SimpleTest test body ' . $this->randomName(32) . ' ' . $this->randomName(32); + $edit["body[$locale][0][value]"] = 'SimpleTest test body ' . $this->randomName(32) . ' ' . $this->randomName(32); $edit['book[bid]'] = $book_nid; if ($parent !== NULL) { diff --git a/modules/comment/comment.api.php b/modules/comment/comment.api.php index 0591265..0027171 100644 --- a/modules/comment/comment.api.php +++ b/modules/comment/comment.api.php @@ -65,12 +65,12 @@ function hook_comment_load($comments) { * Passes in the comment the action is being performed on. * @param $view_mode * View mode, e.g. 'full', 'teaser'... - * @param $langcode + * @param $locale * The language code used for rendering. * * @see hook_entity_view() */ -function hook_comment_view($comment, $view_mode, $langcode) { +function hook_comment_view($comment, $view_mode, $locale) { // how old is the comment $comment->time_ago = time() - $comment->changed; } diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 393318a..93b4597 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -906,20 +906,20 @@ function comment_prepare_thread(&$comments) { * The node the comment is attached to. * @param $view_mode * View mode, e.g. 'full', 'teaser'... - * @param $langcode + * @param $locale * (optional) A language code to use for rendering. Defaults to the global * content language of the current request. * * @return * An array as expected by drupal_render(). */ -function comment_view($comment, $node, $view_mode = 'full', $langcode = NULL) { - if (!isset($langcode)) { - $langcode = $GLOBALS['language_content']->language; +function comment_view($comment, $node, $view_mode = 'full', $locale = NULL) { + if (!isset($locale)) { + $locale = $GLOBALS['language_content']->language; } // Populate $comment->content with a render() array. - comment_build_content($comment, $node, $view_mode, $langcode); + comment_build_content($comment, $node, $view_mode, $locale); $build = $comment->content; // We don't need duplicate rendering info in comment->content. @@ -930,7 +930,7 @@ function comment_view($comment, $node, $view_mode = 'full', $langcode = NULL) { '#comment' => $comment, '#node' => $node, '#view_mode' => $view_mode, - '#language' => $langcode, + '#language' => $locale, ); if (empty($comment->in_preview)) { @@ -976,22 +976,22 @@ function comment_view($comment, $node, $view_mode = 'full', $langcode = NULL) { * The node the comment is attached to. * @param $view_mode * View mode, e.g. 'full', 'teaser'... - * @param $langcode + * @param $locale * (optional) A language code to use for rendering. Defaults to the global * content language of the current request. */ -function comment_build_content($comment, $node, $view_mode = 'full', $langcode = NULL) { - if (!isset($langcode)) { - $langcode = $GLOBALS['language_content']->language; +function comment_build_content($comment, $node, $view_mode = 'full', $locale = NULL) { + if (!isset($locale)) { + $locale = $GLOBALS['language_content']->language; } // Remove previously built content, if exists. $comment->content = array(); // Build fields content. - field_attach_prepare_view('comment', array($comment->cid => $comment), $view_mode, $langcode); - entity_prepare_view('comment', array($comment->cid => $comment), $langcode); - $comment->content += field_attach_view('comment', $comment, $view_mode, $langcode); + field_attach_prepare_view('comment', array($comment->cid => $comment), $view_mode, $locale); + entity_prepare_view('comment', array($comment->cid => $comment), $locale); + $comment->content += field_attach_view('comment', $comment, $view_mode, $locale); $comment->content['links'] = array( '#theme' => 'links__comment', @@ -1007,8 +1007,8 @@ function comment_build_content($comment, $node, $view_mode = 'full', $langcode = } // Allow modules to make their own additions to the comment. - module_invoke_all('comment_view', $comment, $view_mode, $langcode); - module_invoke_all('entity_view', $comment, 'comment', $view_mode, $langcode); + module_invoke_all('comment_view', $comment, $view_mode, $locale); + module_invoke_all('entity_view', $comment, 'comment', $view_mode, $locale); } /** @@ -1084,22 +1084,22 @@ function comment_links($comment, $node) { * View mode, e.g. 'full', 'teaser'... * @param $weight * An integer representing the weight of the first comment in the list. - * @param $langcode + * @param $locale * A string indicating the language field values are to be shown in. If no * language is provided the current content language is used. * * @return * An array in the format expected by drupal_render(). */ -function comment_view_multiple($comments, $node, $view_mode = 'full', $weight = 0, $langcode = NULL) { - field_attach_prepare_view('comment', $comments, $view_mode, $langcode); - entity_prepare_view('comment', $comments, $langcode); +function comment_view_multiple($comments, $node, $view_mode = 'full', $weight = 0, $locale = NULL) { + field_attach_prepare_view('comment', $comments, $view_mode, $locale); + entity_prepare_view('comment', $comments, $locale); $build = array( '#sorted' => TRUE, ); foreach ($comments as $comment) { - $build[$comment->cid] = comment_view($comment, $node, $view_mode, $langcode); + $build[$comment->cid] = comment_view($comment, $node, $view_mode, $locale); $build[$comment->cid]['#weight'] = $weight; $weight++; } diff --git a/modules/comment/comment.test b/modules/comment/comment.test index c9478f4..97999ec 100644 --- a/modules/comment/comment.test +++ b/modules/comment/comment.test @@ -32,9 +32,9 @@ class CommentHelperCase extends DrupalWebTestCase { * array of values to set contact info. */ function postComment($node, $comment, $subject = '', $contact = NULL) { - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $edit = array(); - $edit['comment_body[' . $langcode . '][0][value]'] = $comment; + $edit['comment_body[' . $locale . '][0][value]'] = $comment; $preview_mode = variable_get('comment_preview_article', DRUPAL_OPTIONAL); $subject_mode = variable_get('comment_subject_field_article', 1); @@ -316,7 +316,7 @@ class CommentInterfaceTest extends CommentHelperCase { * Test comment interface. */ function testCommentInterface() { - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // Set comments to have subject and preview disabled. $this->drupalLogin($this->admin_user); $this->setCommentPreview(DRUPAL_DISABLED); @@ -436,7 +436,7 @@ class CommentInterfaceTest extends CommentHelperCase { $this->assertTrue($this->node, t('Article node created.')); $this->drupalGet('comment/reply/' . $this->node->nid); $this->assertNoText('This discussion is closed', t('Posting to node with comments enabled')); - $this->assertField('edit-comment-body-' . $langcode . '-0-value', t('Comment body field found.')); + $this->assertField('edit-comment-body-' . $locale . '-0-value', t('Comment body field found.')); // Delete comment and make sure that reply is also removed. $this->drupalLogout(); @@ -469,7 +469,7 @@ class CommentInterfaceTest extends CommentHelperCase { * Tests the node comment statistics. */ function testCommentNodeCommentStatistics() { - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // Set comments to have subject and preview disabled. $this->drupalLogin($this->admin_user); $this->setCommentPreview(DRUPAL_DISABLED); @@ -839,7 +839,7 @@ class CommentPreviewTest extends CommentHelperCase { * Test comment preview. */ function testCommentPreview() { - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // As admin user, configure comment settings. $this->drupalLogin($this->admin_user); @@ -853,24 +853,24 @@ class CommentPreviewTest extends CommentHelperCase { $this->drupalLogin($this->web_user); $edit = array(); $edit['subject'] = $this->randomName(8); - $edit['comment_body[' . $langcode . '][0][value]'] = $this->randomName(16); + $edit['comment_body[' . $locale . '][0][value]'] = $this->randomName(16); $this->drupalPost('node/' . $this->node->nid, $edit, t('Preview')); // Check that the preview is displaying the title and body. $this->assertTitle(t('Preview comment | Drupal'), t('Page title is "Preview comment".')); $this->assertText($edit['subject'], t('Subject displayed.')); - $this->assertText($edit['comment_body[' . $langcode . '][0][value]'], t('Comment displayed.')); + $this->assertText($edit['comment_body[' . $locale . '][0][value]'], t('Comment displayed.')); // Check that the title and body fields are displayed with the correct values. $this->assertFieldByName('subject', $edit['subject'], t('Subject field displayed.')); - $this->assertFieldByName('comment_body[' . $langcode . '][0][value]', $edit['comment_body[' . $langcode . '][0][value]'], t('Comment field displayed.')); + $this->assertFieldByName('comment_body[' . $locale . '][0][value]', $edit['comment_body[' . $locale . '][0][value]'], t('Comment field displayed.')); } /** * Test comment edit, preview, and save. */ function testCommentEditPreviewSave() { - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'skip comment approval')); $this->drupalLogin($this->admin_user); $this->setCommentPreview(DRUPAL_OPTIONAL); @@ -880,25 +880,25 @@ class CommentPreviewTest extends CommentHelperCase { $edit = array(); $edit['subject'] = $this->randomName(8); - $edit['comment_body[' . $langcode . '][0][value]'] = $this->randomName(16); + $edit['comment_body[' . $locale . '][0][value]'] = $this->randomName(16); $edit['name'] = $web_user->name; $edit['date'] = '2008-03-02 17:23 +0300'; $raw_date = strtotime($edit['date']); $expected_text_date = format_date($raw_date); $expected_form_date = format_date($raw_date, 'custom', 'Y-m-d H:i O'); - $comment = $this->postComment($this->node, $edit['subject'], $edit['comment_body[' . $langcode . '][0][value]'], TRUE); + $comment = $this->postComment($this->node, $edit['subject'], $edit['comment_body[' . $locale . '][0][value]'], TRUE); $this->drupalPost('comment/' . $comment->id . '/edit', $edit, t('Preview')); // Check that the preview is displaying the subject, comment, author and date correctly. $this->assertTitle(t('Preview comment | Drupal'), t('Page title is "Preview comment".')); $this->assertText($edit['subject'], t('Subject displayed.')); - $this->assertText($edit['comment_body[' . $langcode . '][0][value]'], t('Comment displayed.')); + $this->assertText($edit['comment_body[' . $locale . '][0][value]'], t('Comment displayed.')); $this->assertText($edit['name'], t('Author displayed.')); $this->assertText($expected_text_date, t('Date displayed.')); // Check that the subject, comment, author and date fields are displayed with the correct values. $this->assertFieldByName('subject', $edit['subject'], t('Subject field displayed.')); - $this->assertFieldByName('comment_body[' . $langcode . '][0][value]', $edit['comment_body[' . $langcode . '][0][value]'], t('Comment field displayed.')); + $this->assertFieldByName('comment_body[' . $locale . '][0][value]', $edit['comment_body[' . $locale . '][0][value]'], t('Comment field displayed.')); $this->assertFieldByName('name', $edit['name'], t('Author field displayed.')); $this->assertFieldByName('date', $edit['date'], t('Date field displayed.')); @@ -909,14 +909,14 @@ class CommentPreviewTest extends CommentHelperCase { // Check that the comment fields are correct after loading the saved comment. $this->drupalGet('comment/' . $comment->id . '/edit'); $this->assertFieldByName('subject', $edit['subject'], t('Subject field displayed.')); - $this->assertFieldByName('comment_body[' . $langcode . '][0][value]', $edit['comment_body[' . $langcode . '][0][value]'], t('Comment field displayed.')); + $this->assertFieldByName('comment_body[' . $locale . '][0][value]', $edit['comment_body[' . $locale . '][0][value]'], t('Comment field displayed.')); $this->assertFieldByName('name', $edit['name'], t('Author field displayed.')); $this->assertFieldByName('date', $expected_form_date, t('Date field displayed.')); // Submit the form using the displayed values. $displayed = array(); $displayed['subject'] = (string) current($this->xpath("//input[@id='edit-subject']/@value")); - $displayed['comment_body[' . $langcode . '][0][value]'] = (string) current($this->xpath("//textarea[@id='edit-comment-body-" . $langcode . "-0-value']")); + $displayed['comment_body[' . $locale . '][0][value]'] = (string) current($this->xpath("//textarea[@id='edit-comment-body-" . $locale . "-0-value']")); $displayed['name'] = (string) current($this->xpath("//input[@id='edit-name']/@value")); $displayed['date'] = (string) current($this->xpath("//input[@id='edit-date']/@value")); $this->drupalPost('comment/' . $comment->id . '/edit', $displayed, t('Save')); @@ -924,7 +924,7 @@ class CommentPreviewTest extends CommentHelperCase { // Check that the saved comment is still correct. $comment_loaded = comment_load($comment->id); $this->assertEqual($comment_loaded->subject, $edit['subject'], t('Subject loaded.')); - $this->assertEqual($comment_loaded->comment_body[$langcode][0]['value'], $edit['comment_body[' . $langcode . '][0][value]'], t('Comment body loaded.')); + $this->assertEqual($comment_loaded->comment_body[$locale][0]['value'], $edit['comment_body[' . $locale . '][0][value]'], t('Comment body loaded.')); $this->assertEqual($comment_loaded->name, $edit['name'], t('Name loaded.')); $this->assertEqual($comment_loaded->created, $raw_date, t('Date loaded.')); @@ -982,12 +982,12 @@ class CommentAnonymous extends CommentHelperCase { $this->assertTrue($this->commentExists($anonymous_comment2), t('Anonymous comment with contact info (optional) found.')); // Ensure anonymous users cannot post in the name of registered users. - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $edit = array( 'name' => $this->admin_user->name, 'mail' => $this->randomName() . '@example.com', 'subject' => $this->randomName(), - "comment_body[$langcode][0][value]" => $this->randomName(), + "comment_body[$locale][0][value]" => $this->randomName(), ); $this->drupalPost('comment/reply/' . $this->node->nid, $edit, t('Save')); $this->assertText(t('The name you used belongs to a registered user.')); @@ -1054,7 +1054,7 @@ class CommentAnonymous extends CommentHelperCase { $this->drupalGet('comment/reply/' . $this->node->nid); $this->assertText('You are not authorized to post comments', t('Error attempting to post comment.')); $this->assertNoFieldByName('subject', '', t('Subject field not found.')); - $this->assertNoFieldByName("comment_body[$langcode][0][value]", '', t('Comment field not found.')); + $this->assertNoFieldByName("comment_body[$locale][0][value]", '', t('Comment field not found.')); user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array( 'access comments' => TRUE, @@ -1074,7 +1074,7 @@ class CommentAnonymous extends CommentHelperCase { $this->drupalGet('node/' . $this->node->nid); $this->assertNoPattern('@]*>Comments@', t('Comments were not displayed.')); $this->assertFieldByName('subject', '', t('Subject field found.')); - $this->assertFieldByName("comment_body[$langcode][0][value]", '', t('Comment field found.')); + $this->assertFieldByName("comment_body[$locale][0][value]", '', t('Comment field found.')); $this->drupalGet('comment/reply/' . $this->node->nid . '/' . $anonymous_comment3->id); $this->assertText('You are not authorized to view comments', t('Error attempting to post reply.')); @@ -1378,7 +1378,7 @@ class CommentNodeAccessTest extends CommentHelperCase { * Test that threaded comments can be viewed. */ function testThreadedCommentView() { - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // Set comments to have subject required and preview disabled. $this->drupalLogin($this->admin_user); $this->setCommentPreview(DRUPAL_DISABLED); diff --git a/modules/contact/contact.module b/modules/contact/contact.module index eaae9c6..78316c9 100644 --- a/modules/contact/contact.module +++ b/modules/contact/contact.module @@ -181,13 +181,13 @@ function contact_mail($key, &$message, $params) { switch ($key) { case 'page_mail': case 'page_copy': - $message['subject'] .= t('[!category] !subject', $variables, array('langcode' => $language->language)); - $message['body'][] = t("!sender-name (!sender-url) sent a message using the contact form at !form-url.", $variables, array('langcode' => $language->language)); + $message['subject'] .= t('[!category] !subject', $variables, array('locale' => $language->language)); + $message['body'][] = t("!sender-name (!sender-url) sent a message using the contact form at !form-url.", $variables, array('locale' => $language->language)); $message['body'][] = $params['message']; break; case 'page_autoreply': - $message['subject'] .= t('[!category] !subject', $variables, array('langcode' => $language->language)); + $message['subject'] .= t('[!category] !subject', $variables, array('locale' => $language->language)); $message['body'][] = $params['category']['reply']; break; @@ -197,11 +197,11 @@ function contact_mail($key, &$message, $params) { '!recipient-name' => format_username($params['recipient']), '!recipient-edit-url' => url('user/' . $params['recipient']->uid . '/edit', array('absolute' => TRUE, 'language' => $language)), ); - $message['subject'] .= t('[!site-name] !subject', $variables, array('langcode' => $language->language)); - $message['body'][] = t('Hello !recipient-name,', $variables, array('langcode' => $language->language)); - $message['body'][] = t("!sender-name (!sender-url) has sent you a message via your contact form (!form-url) at !site-name.", $variables, array('langcode' => $language->language)); - $message['body'][] = t("If you don't want to receive such e-mails, you can change your settings at !recipient-edit-url.", $variables, array('langcode' => $language->language)); - $message['body'][] = t('Message:', array(), array('langcode' => $language->language)); + $message['subject'] .= t('[!site-name] !subject', $variables, array('locale' => $language->language)); + $message['body'][] = t('Hello !recipient-name,', $variables, array('locale' => $language->language)); + $message['body'][] = t("!sender-name (!sender-url) has sent you a message via your contact form (!form-url) at !site-name.", $variables, array('locale' => $language->language)); + $message['body'][] = t("If you don't want to receive such e-mails, you can change your settings at !recipient-edit-url.", $variables, array('locale' => $language->language)); + $message['body'][] = t('Message:', array(), array('locale' => $language->language)); $message['body'][] = $params['message']; break; } diff --git a/modules/dblog/dblog.test b/modules/dblog/dblog.test index 5717455..26cb891 100644 --- a/modules/dblog/dblog.test +++ b/modules/dblog/dblog.test @@ -273,7 +273,7 @@ class DBLogTestCase extends DrupalWebTestCase { // Create node using form to generate add content event (which is not triggered by drupalCreateNode). $edit = $this->getContent($type); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $title = $edit["title"]; $this->drupalPost('node/add/' . $type, $edit, t('Save')); $this->assertResponse(200); @@ -328,7 +328,7 @@ class DBLogTestCase extends DrupalWebTestCase { * @return array Content. */ private function getContent($type) { - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; switch ($type) { case 'poll': $content = array( @@ -341,7 +341,7 @@ class DBLogTestCase extends DrupalWebTestCase { default: $content = array( "title" => $this->randomName(8), - "body[$langcode][0][value]" => $this->randomName(32), + "body[$locale][0][value]" => $this->randomName(32), ); break; } @@ -364,9 +364,9 @@ class DBLogTestCase extends DrupalWebTestCase { break; default: - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $content = array( - "body[$langcode][0][value]" => $this->randomName(32), + "body[$locale][0][value]" => $this->randomName(32), ); break; } diff --git a/modules/field/field.api.php b/modules/field/field.api.php index 3287dd5..87825e2 100644 --- a/modules/field/field.api.php +++ b/modules/field/field.api.php @@ -301,7 +301,7 @@ function hook_field_schema($field) { * @param $instances * Array of instance structures for $field for each entity, keyed by entity * ID. - * @param $langcode + * @param $locale * The language code associated with $items. * @param $items * Array of field values already loaded for the entities, keyed by entity ID. @@ -310,7 +310,7 @@ function hook_field_schema($field) { * FIELD_LOAD_CURRENT to load the most recent revision for all fields, or * FIELD_LOAD_REVISION to load the version indicated by each entity. */ -function hook_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) { +function hook_field_load($entity_type, $entities, $field, $instances, $locale, &$items, $age) { // Sample code from text.module: precompute sanitized strings so they are // stored in the field cache. foreach ($entities as $id => $entity) { @@ -318,9 +318,9 @@ function hook_field_load($entity_type, $entities, $field, $instances, $langcode, // Only process items with a cacheable format, the rest will be handled // by formatters if needed. if (empty($instances[$id]['settings']['text_processing']) || filter_format_allowcache($item['format'])) { - $items[$id][$delta]['safe_value'] = isset($item['value']) ? _text_sanitize($instances[$id], $langcode, $item, 'value') : ''; + $items[$id][$delta]['safe_value'] = isset($item['value']) ? _text_sanitize($instances[$id], $locale, $item, 'value') : ''; if ($field['type'] == 'text_with_summary') { - $items[$id][$delta]['safe_summary'] = isset($item['summary']) ? _text_sanitize($instances[$id], $langcode, $item, 'summary') : ''; + $items[$id][$delta]['safe_summary'] = isset($item['summary']) ? _text_sanitize($instances[$id], $locale, $item, 'summary') : ''; } } } @@ -351,12 +351,12 @@ function hook_field_load($entity_type, $entities, $field, $instances, $langcode, * @param $instances * Array of instance structures for $field for each entity, keyed by entity * ID. - * @param $langcode + * @param $locale * The language associated to $items. * @param $items * $entity->{$field['field_name']}, or an empty array if unset. */ -function hook_field_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items) { +function hook_field_prepare_view($entity_type, $entities, $field, $instances, $locale, &$items) { // Sample code from image.module: if there are no images specified at all, // use the default image. foreach ($entities as $id => $entity) { @@ -386,10 +386,10 @@ function hook_field_prepare_view($entity_type, $entities, $field, $instances, $l * The field structure for the operation. * @param $instance * The instance structure for $field on $entity's bundle. - * @param $langcode + * @param $locale * The language associated with $items. * @param $items - * $entity->{$field['field_name']}[$langcode], or an empty array if unset. + * $entity->{$field['field_name']}[$locale], or an empty array if unset. * @param $errors * The array of errors (keyed by field name, language code, and delta) that * have already been reported for the entity. The function should add its @@ -398,11 +398,11 @@ function hook_field_prepare_view($entity_type, $entities, $field, $instances, $l * - error: An error code (should be a string prefixed with the module name). * - message: The human readable message to be displayed. */ -function hook_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) { +function hook_field_validate($entity_type, $entity, $field, $instance, $locale, $items, &$errors) { foreach ($items as $delta => $item) { if (!empty($item['value'])) { if (!empty($field['settings']['max_length']) && drupal_strlen($item['value']) > $field['settings']['max_length']) { - $errors[$field['field_name']][$langcode][$delta][] = array( + $errors[$field['field_name']][$locale][$delta][] = array( 'error' => 'text_max_length', 'message' => t('%name: the value may not be longer than %max characters.', array('%name' => $instance['label'], '%max' => $field['settings']['max_length'])), ); @@ -425,12 +425,12 @@ function hook_field_validate($entity_type, $entity, $field, $instance, $langcode * The field structure for the operation. * @param $instance * The instance structure for $field on $entity's bundle. - * @param $langcode + * @param $locale * The language associated with $items. * @param $items - * $entity->{$field['field_name']}[$langcode], or an empty array if unset. + * $entity->{$field['field_name']}[$locale], or an empty array if unset. */ -function hook_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) { +function hook_field_presave($entity_type, $entity, $field, $instance, $locale, &$items) { if ($field['type'] == 'number_decimal') { // Let PHP round the value to ensure consistent behavior across storage // backends. @@ -455,12 +455,12 @@ function hook_field_presave($entity_type, $entity, $field, $instance, $langcode, * The field structure for the operation. * @param $instance * The instance structure for $field on $entity's bundle. - * @param $langcode + * @param $locale * The language associated with $items. * @param $items - * $entity->{$field['field_name']}[$langcode], or an empty array if unset. + * $entity->{$field['field_name']}[$locale], or an empty array if unset. */ -function hook_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) { +function hook_field_insert($entity_type, $entity, $field, $instance, $locale, &$items) { if (variable_get('taxonomy_maintain_index_table', TRUE) && $field['storage']['type'] == 'field_sql_storage' && $entity_type == 'node' && $entity->status) { $query = db_insert('taxonomy_index')->fields(array('nid', 'tid', 'sticky', 'created', )); foreach ($items as $item) { @@ -488,12 +488,12 @@ function hook_field_insert($entity_type, $entity, $field, $instance, $langcode, * The field structure for the operation. * @param $instance * The instance structure for $field on $entity's bundle. - * @param $langcode + * @param $locale * The language associated with $items. * @param $items - * $entity->{$field['field_name']}[$langcode], or an empty array if unset. + * $entity->{$field['field_name']}[$locale], or an empty array if unset. */ -function hook_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) { +function hook_field_update($entity_type, $entity, $field, $instance, $locale, &$items) { if (variable_get('taxonomy_maintain_index_table', TRUE) && $field['storage']['type'] == 'field_sql_storage' && $entity_type == 'node') { $first_call = &drupal_static(__FUNCTION__, array()); @@ -570,12 +570,12 @@ function hook_field_storage_update_field($field, $prior_field, $has_data) { * The field structure for the operation. * @param $instance * The instance structure for $field on $entity's bundle. - * @param $langcode + * @param $locale * The language associated with $items. * @param $items - * $entity->{$field['field_name']}[$langcode], or an empty array if unset. + * $entity->{$field['field_name']}[$locale], or an empty array if unset. */ -function hook_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items) { +function hook_field_delete($entity_type, $entity, $field, $instance, $locale, &$items) { list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity); foreach ($items as $delta => $item) { // For hook_file_references(), remember that this is being deleted. @@ -603,12 +603,12 @@ function hook_field_delete($entity_type, $entity, $field, $instance, $langcode, * The field structure for the operation. * @param $instance * The instance structure for $field on $entity's bundle. - * @param $langcode + * @param $locale * The language associated with $items. * @param $items - * $entity->{$field['field_name']}[$langcode], or an empty array if unset. + * $entity->{$field['field_name']}[$locale], or an empty array if unset. */ -function hook_field_delete_revision($entity_type, $entity, $field, $instance, $langcode, &$items) { +function hook_field_delete_revision($entity_type, $entity, $field, $instance, $locale, &$items) { foreach ($items as $delta => $item) { // For hook_file_references, remember that this file is being deleted. $item['file_field_name'] = $field['field_name']; @@ -629,21 +629,21 @@ function hook_field_delete_revision($entity_type, $entity, $field, $instance, $l * The field structure for the operation. * @param $instance * The instance structure for $field on $entity's bundle. - * @param $langcode + * @param $locale * The language associated to $items. * @param $items - * $entity->{$field['field_name']}[$langcode], or an empty array if unset. + * $entity->{$field['field_name']}[$locale], or an empty array if unset. * @param $source_entity * The source entity from which field values are being copied. - * @param $source_langcode + * @param $source_locale * The source language from which field values are being copied. */ -function hook_field_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode) { +function hook_field_prepare_translation($entity_type, $entity, $field, $instance, $locale, &$items, $source_entity, $source_locale) { // If the translating user is not permitted to use the assigned text format, // we must not expose the source values. $field_name = $field['field_name']; $formats = filter_formats(); - $format_id = $source_entity->{$field_name}[$source_langcode][0]['format']; + $format_id = $source_entity->{$field_name}[$source_locale][0]['format']; if (!filter_access($formats[$format_id])) { $items = array(); } @@ -795,7 +795,7 @@ function hook_field_widget_info_alter(&$info) { * The field structure. * @param $instance * The field instance. - * @param $langcode + * @param $locale * The language associated with $items. * @param $items * Array of default values for this field. @@ -827,7 +827,7 @@ function hook_field_widget_info_alter(&$info) { * @return * The form elements for a single widget for this field. */ -function hook_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) { +function hook_field_widget_form(&$form, &$form_state, $field, $instance, $locale, $items, $delta, $element) { $element += array( '#type' => $instance['widget']['type'], '#default_value' => isset($items[$delta]) ? $items[$delta] : '', @@ -954,7 +954,7 @@ function hook_field_formatter_info_alter(&$info) { * @param $instances * Array of instance structures for $field for each entity, keyed by entity * ID. - * @param $langcode + * @param $locale * The language the field values are to be shown in. If no language is * provided the current language is used. * @param $items @@ -966,7 +966,7 @@ function hook_field_formatter_info_alter(&$info) { * Changes or additions to field values are done by altering the $items * parameter by reference. */ -function hook_field_formatter_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $displays) { +function hook_field_formatter_prepare_view($entity_type, $entities, $field, $instances, $locale, &$items, $displays) { $tids = array(); // Collect every possible term attached to any of the fieldable entities. @@ -1017,7 +1017,7 @@ function hook_field_formatter_prepare_view($entity_type, $entities, $field, $ins * The field structure. * @param $instance * The field instance. - * @param $langcode + * @param $locale * The language associated with $items. * @param $items * Array of values for this field. @@ -1031,7 +1031,7 @@ function hook_field_formatter_prepare_view($entity_type, $entities, $field, $ins * A renderable array for the $items, as an array of child elements keyed * by numeric indexes starting from 0. */ -function hook_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { +function hook_field_formatter_view($entity_type, $entity, $field, $instance, $locale, $items, $display) { $element = array(); $settings = $display['settings']; @@ -1104,11 +1104,11 @@ function hook_field_formatter_view($entity_type, $entity, $field, $instance, $la * act on the $complete_form parameter in the process callback. * @param $form_state * An associative array containing the current state of the form. - * @param $langcode + * @param $locale * The language the field values are going to be entered in. If no language * is provided the default site language will be used. */ -function hook_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) { +function hook_field_attach_form($entity_type, $entity, &$form, &$form_state, $locale) { // Add a checkbox allowing a given field to be emptied. // See hook_field_attach_submit() for the corresponding processing code. $form['empty_field_foo'] = array( @@ -1323,9 +1323,9 @@ function hook_field_attach_view_alter(&$output, $context) { * @param $context * An associative array containing: * - entity_type: The type of $entity; e.g. 'node' or 'user'. - * - langcode: The language the entity has to be translated in. + * - locale: The language the entity has to be translated in. * - source_entity: The entity holding the field values to be translated. - * - source_langcode: The source language from which translate. + * - source_locale: The source language from which translate. */ function hook_field_attach_prepare_translation_alter(&$entity, $context) { if ($context['entity_type'] == 'custom_entity_type') { @@ -1345,7 +1345,7 @@ function hook_field_attach_prepare_translation_alter(&$entity, $context) { * An associative array containing: * - entity_type: The type of the entity to be displayed. * - entity: The entity with fields to render. - * - langcode: The language code $entity has to be displayed in. + * - locale: The language code $entity has to be displayed in. */ function hook_field_language_alter(&$display_language, $context) { // Do not apply core language fallback rules if they are disabled or if Locale @@ -1686,8 +1686,8 @@ function hook_field_storage_write($entity_type, $entity, $op, $fields) { $query = db_insert($table_name)->fields($columns); $revision_query = db_insert($revision_name)->fields($columns); - foreach ($field_languages as $langcode) { - $items = (array) $entity->{$field_name}[$langcode]; + foreach ($field_languages as $locale) { + $items = (array) $entity->{$field_name}[$locale]; $delta_count = 0; foreach ($items as $delta => $item) { // We now know we have someting to insert. @@ -1698,7 +1698,7 @@ function hook_field_storage_write($entity_type, $entity, $op, $fields) { 'revision_id' => $vid, 'bundle' => $bundle, 'delta' => $delta, - 'language' => $langcode, + 'language' => $locale, ); foreach ($field['columns'] as $column => $attributes) { $record[_field_sql_storage_columnname($field_name, $column)] = isset($item[$column]) ? $item[$column] : NULL; diff --git a/modules/field/field.attach.inc b/modules/field/field.attach.inc index 2419201..0bf61dd 100644 --- a/modules/field/field.attach.inc +++ b/modules/field/field.attach.inc @@ -193,9 +193,9 @@ function _field_invoke($op, $entity_type, $entity, &$a = NULL, &$b = NULL, $opti $available_languages = field_available_languages($entity_type, $field); $languages = _field_language_suggestion($available_languages, $options['language'], $field_name); - foreach ($languages as $langcode) { - $items = isset($entity->{$field_name}[$langcode]) ? $entity->{$field_name}[$langcode] : array(); - $result = $function($entity_type, $entity, $field, $instance, $langcode, $items, $a, $b); + foreach ($languages as $locale) { + $items = isset($entity->{$field_name}[$locale]) ? $entity->{$field_name}[$locale] : array(); + $result = $function($entity_type, $entity, $field, $instance, $locale, $items, $a, $b); if (isset($result)) { // For hooks with array results, we merge results together. // For hooks with scalar results, we collect results in an array. @@ -209,8 +209,8 @@ function _field_invoke($op, $entity_type, $entity, &$a = NULL, &$b = NULL, $opti // Populate $items back in the field values, but avoid replacing missing // fields with an empty array (those are not equivalent on update). - if ($items !== array() || isset($entity->{$field_name}[$langcode])) { - $entity->{$field_name}[$langcode] = $items; + if ($items !== array() || isset($entity->{$field_name}[$locale])) { + $entity->{$field_name}[$locale] = $items; } } } @@ -310,12 +310,12 @@ function _field_invoke_multiple($op, $entity_type, $entities, &$a = NULL, &$b = $available_languages = field_available_languages($entity_type, $field); $language = !empty($options['language'][$id]) ? $options['language'][$id] : $options['language']; $languages = _field_language_suggestion($available_languages, $language, $field_name); - foreach ($languages as $langcode) { - $grouped_items[$field_id][$langcode][$id] = isset($entity->{$field_name}[$langcode]) ? $entity->{$field_name}[$langcode] : array(); + foreach ($languages as $locale) { + $grouped_items[$field_id][$locale][$id] = isset($entity->{$field_name}[$locale]) ? $entity->{$field_name}[$locale] : array(); // Group the instances and entities corresponding to the current // field. - $grouped_instances[$field_id][$langcode][$id] = $instance; - $grouped_entities[$field_id][$langcode][$id] = $entities[$id]; + $grouped_instances[$field_id][$locale][$id] = $instance; + $grouped_entities[$field_id][$locale][$id] = $entities[$id]; } } } @@ -328,10 +328,10 @@ function _field_invoke_multiple($op, $entity_type, $entities, &$a = NULL, &$b = $field_name = $field['field_name']; $function = $options['default'] ? 'field_default_' . $op : $field['module'] . '_field_' . $op; // Iterate over all the field translations. - foreach ($grouped_items[$field_id] as $langcode => &$items) { - $entities = $grouped_entities[$field_id][$langcode]; - $instances = $grouped_instances[$field_id][$langcode]; - $results = $function($entity_type, $entities, $field, $instances, $langcode, $items, $a, $b); + foreach ($grouped_items[$field_id] as $locale => &$items) { + $entities = $grouped_entities[$field_id][$locale]; + $instances = $grouped_instances[$field_id][$locale]; + $results = $function($entity_type, $entities, $field, $instances, $locale, $items, $a, $b); if (isset($results)) { // Collect results by entity. // For hooks with array results, we merge results together. @@ -349,10 +349,10 @@ function _field_invoke_multiple($op, $entity_type, $entities, &$a = NULL, &$b = // Populate field values back in the entities, but avoid replacing missing // fields with an empty array (those are not equivalent on update). - foreach ($grouped_entities[$field_id] as $langcode => $entities) { + foreach ($grouped_entities[$field_id] as $locale => $entities) { foreach ($entities as $id => $entity) { - if ($grouped_items[$field_id][$langcode][$id] !== array() || isset($entity->{$field_name}[$langcode])) { - $entity->{$field_name}[$langcode] = $grouped_items[$field_id][$langcode][$id]; + if ($grouped_items[$field_id][$locale][$id] !== array() || isset($entity->{$field_name}[$locale])) { + $entity->{$field_name}[$locale] = $grouped_items[$field_id][$locale][$id]; } } } @@ -470,17 +470,17 @@ function _field_invoke_get_instances($entity_type, $bundle, $options) { * // most common case), and will therefore be repeated as many times as * // needed, or 'multiple-values' (one single widget allows the input of * // several values, e.g checkboxes, select box...). - * // The sub-array is nested into a $langcode key where $langcode has the - * // same value of the $langcode parameter above. - * // The '#language' key holds the same value of $langcode and it is used - * // to access the field sub-array when $langcode is unknown. + * // The sub-array is nested into a $locale key where $locale has the + * // same value of the $locale parameter above. + * // The '#language' key holds the same value of $locale and it is used + * // to access the field sub-array when $locale is unknown. * 'field_foo' => array( * '#tree' => TRUE, * '#field_name' => The name of the field, - * '#language' => $langcode, - * $langcode => array( + * '#language' => $locale, + * $locale => array( * '#field_name' => The name of the field, - * '#language' => $langcode, + * '#language' => $locale, * '#field_parents' => The 'parents' space for the field in the form, * equal to the #parents property of the $form parameter received by * field_attach_form(), @@ -541,19 +541,19 @@ function _field_invoke_get_instances($entity_type, $bundle, $options) { * values at the top-level of $form_state['values']. * @param $form_state * An associative array containing the current state of the form. - * @param $langcode + * @param $locale * The language the field values are going to be entered, if no language * is provided the default site language will be used. * * @see field_form_get_state() * @see field_form_set_state() */ -function field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode = NULL) { +function field_attach_form($entity_type, $entity, &$form, &$form_state, $locale = NULL) { // Set #parents to 'top-level' by default. $form += array('#parents' => array()); // If no language is provided use the default site language. - $options = array('language' => field_valid_language($langcode)); + $options = array('language' => field_valid_language($locale)); $form += (array) _field_invoke_default('form', $entity_type, $entity, $form, $form_state, $options); // Add custom weight handling. @@ -566,7 +566,7 @@ function field_attach_form($entity_type, $entity, &$form, &$form_state, $langcod // Avoid module_invoke_all() to let parameters be taken by reference. foreach (module_implements('field_attach_form') as $module) { $function = $module . '_field_attach_form'; - $function($entity_type, $entity, $form, $form_state, $langcode); + $function($entity_type, $entity, $form, $form_state, $locale); } } @@ -818,10 +818,10 @@ function field_attach_form_validate($entity_type, $entity, $form, &$form_state) // Pass field-level validation errors back to widgets for accurate error // flagging. foreach ($e->errors as $field_name => $field_errors) { - foreach ($field_errors as $langcode => $errors) { - $field_state = field_form_get_state($form['#parents'], $field_name, $langcode, $form_state); + foreach ($field_errors as $locale => $errors) { + $field_state = field_form_get_state($form['#parents'], $field_name, $locale, $form_state); $field_state['errors'] = $errors; - field_form_set_state($form['#parents'], $field_name, $langcode, $form_state, $field_state); + field_form_set_state($form['#parents'], $field_name, $locale, $form_state, $field_state); } } _field_invoke_default('form_errors', $entity_type, $entity, $form, $form_state); @@ -1078,11 +1078,11 @@ function field_attach_delete_revision($entity_type, $entity) { * An array of entities, keyed by entity id. * @param $view_mode * View mode, e.g. 'full', 'teaser'... - * @param $langcode + * @param $locale * (Optional) The language the field values are to be shown in. If no language * is provided the current language is used. */ -function field_attach_prepare_view($entity_type, $entities, $view_mode, $langcode = NULL) { +function field_attach_prepare_view($entity_type, $entities, $view_mode, $locale = NULL) { $options = array('language' => array()); // To ensure hooks are only run once per entity, only process items without @@ -1096,7 +1096,7 @@ function field_attach_prepare_view($entity_type, $entities, $view_mode, $langcod // Determine the actual language to display for each field, given the // languages available in the field data. - $options['language'][$id] = field_language($entity_type, $entity, NULL, $langcode); + $options['language'][$id] = field_language($entity_type, $entity, NULL, $locale); // Mark this item as prepared. $entity->_field_view_prepared = TRUE; @@ -1152,16 +1152,16 @@ function field_attach_prepare_view($entity_type, $entities, $view_mode, $langcod * The entity with fields to render. * @param $view_mode * View mode, e.g. 'full', 'teaser'... - * @param $langcode + * @param $locale * The language the field values are to be shown in. If no language is * provided the current language is used. * @return * A renderable array for the field values. */ -function field_attach_view($entity_type, $entity, $view_mode, $langcode = NULL) { +function field_attach_view($entity_type, $entity, $view_mode, $locale = NULL) { // Determine the actual language to display for each field, given the // languages available in the field data. - $display_language = field_language($entity_type, $entity, NULL, $langcode); + $display_language = field_language($entity_type, $entity, NULL, $locale); $options = array('language' => $display_language); // Invoke field_default_view(). @@ -1180,7 +1180,7 @@ function field_attach_view($entity_type, $entity, $view_mode, $langcode = NULL) 'entity' => $entity, 'view_mode' => $view_mode, 'display' => $view_mode, - 'language' => $langcode, + 'language' => $locale, ); drupal_alter('field_attach_view', $output, $context); @@ -1216,8 +1216,8 @@ function field_attach_preprocess($entity_type, $entity, $element, &$variables) { foreach (field_info_instances($entity_type, $bundle) as $instance) { $field_name = $instance['field_name']; if (isset($element[$field_name]['#language'])) { - $langcode = $element[$field_name]['#language']; - $variables[$field_name] = isset($entity->{$field_name}[$langcode]) ? $entity->{$field_name}[$langcode] : NULL; + $locale = $element[$field_name]['#language']; + $variables[$field_name] = isset($entity->{$field_name}[$locale]) ? $entity->{$field_name}[$locale] : NULL; } } @@ -1246,25 +1246,25 @@ function field_attach_preprocess($entity_type, $entity, $element, &$variables) { * The type of $entity; e.g. 'node' or 'user'. * @param $entity * The entity to be prepared for translation. - * @param $langcode + * @param $locale * The language the entity has to be translated in. * @param $source_entity * The source entity holding the field values to be translated. - * @param $source_langcode + * @param $source_locale * The source language from which translate. */ -function field_attach_prepare_translation($entity_type, $entity, $langcode, $source_entity, $source_langcode) { - $options = array('language' => $langcode); +function field_attach_prepare_translation($entity_type, $entity, $locale, $source_entity, $source_locale) { + $options = array('language' => $locale); // Copy source field values into the entity to be prepared. - _field_invoke_default('prepare_translation', $entity_type, $entity, $source_entity, $source_langcode, $options); + _field_invoke_default('prepare_translation', $entity_type, $entity, $source_entity, $source_locale, $options); // Let field types handle their own advanced translation pattern if needed. - _field_invoke('prepare_translation', $entity_type, $entity, $source_entity, $source_langcode, $options); + _field_invoke('prepare_translation', $entity_type, $entity, $source_entity, $source_locale, $options); // Let other modules alter the entity translation. $context = array( 'entity_type' => $entity_type, - 'langcode' => $langcode, + 'locale' => $locale, 'source_entity' => $source_entity, - 'source_langcode' => $source_langcode, + 'source_locale' => $source_locale, ); drupal_alter('field_attach_prepare_translation', $entity, $context); } diff --git a/modules/field/field.default.inc b/modules/field/field.default.inc index a10d138..452547b 100644 --- a/modules/field/field.default.inc +++ b/modules/field/field.default.inc @@ -21,7 +21,7 @@ * The field structure for the operation. * @param $instance * The instance structure for $field on $entity's bundle. - * @param $langcode + * @param $locale * The language associated to $items. * @param $items * The field values. This parameter is altered by reference to receive the @@ -32,8 +32,8 @@ * @param $form_state * The form state. */ -function field_default_extract_form_values($entity_type, $entity, $field, $instance, $langcode, &$items, $form, &$form_state) { - $path = array_merge($form['#parents'], array($field['field_name'], $langcode)); +function field_default_extract_form_values($entity_type, $entity, $field, $instance, $locale, &$items, $form, &$form_state) { + $path = array_merge($form['#parents'], array($field['field_name'], $locale)); $key_exists = NULL; $values = drupal_array_get_nested_value($form_state['values'], $path, $key_exists); if ($key_exists) { @@ -59,10 +59,10 @@ function field_default_extract_form_values($entity_type, $entity, $field, $insta * The field structure for the operation. * @param $instance * The instance structure for $field on $entity's bundle. - * @param $langcode + * @param $locale * The language associated to $items. * @param $items - * $entity->{$field['field_name']}[$langcode], or an empty array if unset. + * $entity->{$field['field_name']}[$locale], or an empty array if unset. * @param $errors * The array of errors, keyed by field name and by value delta, that have * already been reported for the entity. The function should add its errors @@ -71,7 +71,7 @@ function field_default_extract_form_values($entity_type, $entity, $field, $insta * - 'error': an error code (should be a string, prefixed with the module name) * - 'message': the human readable message to be displayed. */ -function field_default_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) { +function field_default_validate($entity_type, $entity, $field, $instance, $locale, $items, &$errors) { // Filter out empty values. $items = _field_filter_items($field, $items); @@ -79,14 +79,14 @@ function field_default_validate($entity_type, $entity, $field, $instance, $langc // For form submitted values, this can only happen with 'multiple value' // widgets. if ($field['cardinality'] != FIELD_CARDINALITY_UNLIMITED && count($items) > $field['cardinality']) { - $errors[$field['field_name']][$langcode][0][] = array( + $errors[$field['field_name']][$locale][0][] = array( 'error' => 'field_cardinality', 'message' => t('%name: this field cannot hold more than @count values.', array('%name' => $instance['label'], '@count' => $field['cardinality'])), ); } } -function field_default_submit($entity_type, $entity, $field, $instance, $langcode, &$items, $form, &$form_state) { +function field_default_submit($entity_type, $entity, $field, $instance, $locale, &$items, $form, &$form_state) { // Filter out empty values. $items = _field_filter_items($field, $items); // Reorder items to account for drag-n-drop reordering. @@ -100,7 +100,7 @@ function field_default_submit($entity_type, $entity, $field, $instance, $langcod * This can happen with programmatic saves, or on form-based creation where * the current user doesn't have 'edit' permission for the field. */ -function field_default_insert($entity_type, $entity, $field, $instance, $langcode, &$items) { +function field_default_insert($entity_type, $entity, $field, $instance, $locale, &$items) { // _field_invoke() populates $items with an empty array if the $entity has no // entry for the field, so we check on the $entity itself. // We also check that the current field translation is actually defined before @@ -108,8 +108,8 @@ function field_default_insert($entity_type, $entity, $field, $instance, $langcod // languages get a default value. Otherwise we could have default values for // not yet open languages. if (empty($entity) || !property_exists($entity, $field['field_name']) || - (isset($entity->{$field['field_name']}[$langcode]) && count($entity->{$field['field_name']}[$langcode]) == 0)) { - $items = field_get_default_value($entity_type, $entity, $field, $instance, $langcode); + (isset($entity->{$field['field_name']}[$locale]) && count($entity->{$field['field_name']}[$locale]) == 0)) { + $items = field_get_default_value($entity_type, $entity, $field, $instance, $locale); } } @@ -125,7 +125,7 @@ function field_default_insert($entity_type, $entity, $field, $instance, $langcod * @param $instances * Array of instance structures for $field for each entity, keyed by entity * id. - * @param $langcode + * @param $locale * The language associated to $items. * @param $items * Array of field values already loaded for the entities, keyed by entity id. @@ -135,7 +135,7 @@ function field_default_insert($entity_type, $entity, $field, $instance, $langcod * - or an array of display settings to use for display, as found in the * 'display' entry of $instance definitions. */ -function field_default_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $display) { +function field_default_prepare_view($entity_type, $entities, $field, $instances, $locale, &$items, $display) { // Group entities, instances and items by formatter module. $modules = array(); foreach ($instances as $id => $instance) { @@ -162,7 +162,7 @@ function field_default_prepare_view($entity_type, $entities, $field, $instances, // Invoke hook_field_formatter_prepare_view(). $function = $module . '_field_formatter_prepare_view'; if (function_exists($function)) { - $function($entity_type, $grouped_entities[$module], $field, $grouped_instances[$module], $langcode, $grouped_items[$module], $grouped_displays[$module]); + $function($entity_type, $grouped_entities[$module], $field, $grouped_instances[$module], $locale, $grouped_items[$module], $grouped_displays[$module]); } } } @@ -179,7 +179,7 @@ function field_default_prepare_view($entity_type, $entities, $field, $instances, * @param $instances * Array of instance structures for $field for each entity, keyed by entity * id. - * @param $langcode + * @param $locale * The language associated to $items. * @param $items * Array of field values already loaded for the entities, keyed by entity id. @@ -189,7 +189,7 @@ function field_default_prepare_view($entity_type, $entities, $field, $instances, * - or an array of custom display settings, as found in the 'display' entry * of $instance definitions. */ -function field_default_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { +function field_default_view($entity_type, $entity, $field, $instance, $locale, $items, $display) { list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity); $addition = array(); @@ -208,7 +208,7 @@ function field_default_view($entity_type, $entity, $field, $instance, $langcode, // performance impact on pages with many fields and values. $function = $display['module'] . '_field_formatter_view'; if (function_exists($function)) { - $elements = $function($entity_type, $entity, $field, $instance, $langcode, $items, $display); + $elements = $function($entity_type, $entity, $field, $instance, $locale, $items, $display); if ($elements) { $info = array( @@ -218,7 +218,7 @@ function field_default_view($entity_type, $entity, $field, $instance, $langcode, '#access' => field_access('view', $field, $entity_type, $entity), '#label_display' => $display['label'], '#view_mode' => $view_mode, - '#language' => $langcode, + '#language' => $locale, '#field_name' => $field['field_name'], '#field_type' => $field['type'], '#field_translatable' => $field['translatable'], @@ -248,22 +248,22 @@ function field_default_view($entity_type, $entity, $field, $instance, $langcode, * The field structure for the operation. * @param $instance * The instance structure for $field on $entity's bundle. - * @param $langcode + * @param $locale * The language the entity has to be translated in. * @param $items - * $entity->{$field['field_name']}[$langcode], or an empty array if unset. + * $entity->{$field['field_name']}[$locale], or an empty array if unset. * @param $source_entity * The source entity holding the field values to be translated. - * @param $source_langcode + * @param $source_locale * The source language from which translate. */ -function field_default_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode) { +function field_default_prepare_translation($entity_type, $entity, $field, $instance, $locale, &$items, $source_entity, $source_locale) { $field_name = $field['field_name']; // If the field is untranslatable keep using LANGUAGE_NONE. - if ($langcode == LANGUAGE_NONE) { - $source_langcode = LANGUAGE_NONE; + if ($locale == LANGUAGE_NONE) { + $source_locale = LANGUAGE_NONE; } - if (isset($source_entity->{$field_name}[$source_langcode])) { - $items = $source_entity->{$field_name}[$source_langcode]; + if (isset($source_entity->{$field_name}[$source_locale])) { + $items = $source_entity->{$field_name}[$source_locale]; } } diff --git a/modules/field/field.form.inc b/modules/field/field.form.inc index 9250a51..93d981d 100644 --- a/modules/field/field.form.inc +++ b/modules/field/field.form.inc @@ -8,7 +8,7 @@ /** * Create a separate form element for each field. */ -function field_default_form($entity_type, $entity, $field, $instance, $langcode, $items, &$form, &$form_state, $get_delta = NULL) { +function field_default_form($entity_type, $entity, $field, $instance, $locale, $items, &$form, &$form_state, $get_delta = NULL) { // This could be called with no entity, as when a UI module creates a // dummy form to set default values. if ($entity) { @@ -23,7 +23,7 @@ function field_default_form($entity_type, $entity, $field, $instance, $langcode, // Populate widgets with default values when creating a new entity. if (empty($items) && empty($id)) { - $items = field_get_default_value($entity_type, $entity, $field, $instance, $langcode); + $items = field_get_default_value($entity_type, $entity, $field, $instance, $locale); } // Let modules alter the widget properties. @@ -39,7 +39,7 @@ function field_default_form($entity_type, $entity, $field, $instance, $langcode, $elements = array(); if (field_access('edit', $field, $entity_type, $entity)) { // Store field information in $form_state. - if (!field_form_get_state($parents, $field_name, $langcode, $form_state)) { + if (!field_form_get_state($parents, $field_name, $locale, $form_state)) { $field_state = array( 'field' => $field, 'instance' => $instance, @@ -47,13 +47,13 @@ function field_default_form($entity_type, $entity, $field, $instance, $langcode, 'array_parents' => array(), 'errors' => array(), ); - field_form_set_state($parents, $field_name, $langcode, $form_state, $field_state); + field_form_set_state($parents, $field_name, $locale, $form_state, $field_state); } // If field module handles multiple values for this form element, and we // are displaying an individual element, process the multiple value form. if (!isset($get_delta) && field_behaviors_widget('multiple values', $instance) == FIELD_BEHAVIOR_DEFAULT) { - $elements = field_multiple_value_form($field, $instance, $langcode, $items, $form, $form_state); + $elements = field_multiple_value_form($field, $instance, $locale, $items, $form, $form_state); } // If the widget is handling multiple values (e.g Options), or if we are // displaying an individual element, just get a single form element and @@ -66,7 +66,7 @@ function field_default_form($entity_type, $entity, $field, $instance, $langcode, '#entity_type' => $instance['entity_type'], '#bundle' => $instance['bundle'], '#field_name' => $field_name, - '#language' => $langcode, + '#language' => $locale, '#field_parents' => $parents, '#columns' => array_keys($field['columns']), '#title' => check_plain($instance['label']), @@ -75,7 +75,7 @@ function field_default_form($entity_type, $entity, $field, $instance, $langcode, '#required' => $delta == 0 && $instance['required'], '#delta' => $delta, ); - if ($element = $function($form, $form_state, $field, $instance, $langcode, $items, $delta, $element)) { + if ($element = $function($form, $form_state, $field, $instance, $locale, $items, $delta, $element)) { // If we're processing a specific delta value for a field where the // field module handles multiples, set the delta in the result. // For fields that handle their own processing, we can't make @@ -113,15 +113,15 @@ function field_default_form($entity_type, $entity, $field, $instance, $langcode, // in alter() hooks. $elements['#after_build'][] = 'field_form_element_after_build'; $elements['#field_name'] = $field_name; - $elements['#language'] = $langcode; + $elements['#language'] = $locale; $elements['#field_parents'] = $parents; $addition[$field_name] += array( '#tree' => TRUE, // The '#language' key can be used to access the field's form element - // when $langcode is unknown. - '#language' => $langcode, - $langcode => $elements, + // when $locale is unknown. + '#language' => $locale, + $locale => $elements, ); return $addition; @@ -135,14 +135,14 @@ function field_default_form($entity_type, $entity, $field, $instance, $langcode, * - AHAH-'add more' button * - drag-n-drop value reordering */ -function field_multiple_value_form($field, $instance, $langcode, $items, &$form, &$form_state) { +function field_multiple_value_form($field, $instance, $locale, $items, &$form, &$form_state) { $field_name = $field['field_name']; $parents = $form['#parents']; // Determine the number of widgets to display. switch ($field['cardinality']) { case FIELD_CARDINALITY_UNLIMITED: - $field_state = field_form_get_state($parents, $field_name, $langcode, $form_state); + $field_state = field_form_get_state($parents, $field_name, $locale, $form_state); $max = $field_state['items_count']; break; @@ -167,7 +167,7 @@ function field_multiple_value_form($field, $instance, $langcode, $items, &$form, '#entity_type' => $instance['entity_type'], '#bundle' => $instance['bundle'], '#field_name' => $field_name, - '#language' => $langcode, + '#language' => $locale, '#field_parents' => $parents, '#columns' => array_keys($field['columns']), // For multiple fields, title and description are handled by the wrapping table. @@ -178,7 +178,7 @@ function field_multiple_value_form($field, $instance, $langcode, $items, &$form, '#delta' => $delta, '#weight' => $delta, ); - if ($element = $function($form, $form_state, $field, $instance, $langcode, $items, $delta, $element)) { + if ($element = $function($form, $form_state, $field, $instance, $locale, $items, $delta, $element)) { // Input field for the delta (drag-n-drop reordering). if ($multiple) { // We name the element '_weight' to avoid clashing with elements @@ -216,7 +216,7 @@ function field_multiple_value_form($field, $instance, $langcode, $items, &$form, '#name' => strtr($id_prefix, '-', '_') . '_add_more', '#value' => t('Add another item'), '#attributes' => array('class' => array('field-add-more-submit')), - '#limit_validation_errors' => array(array_merge($parents, array($field_name, $langcode))), + '#limit_validation_errors' => array(array_merge($parents, array($field_name, $locale))), '#submit' => array('field_add_more_submit'), '#ajax' => array( 'callback' => 'field_add_more_js', @@ -319,11 +319,11 @@ function theme_field_multiple_value_form($variables) { function field_form_element_after_build($element, &$form_state) { $parents = $element['#field_parents']; $field_name = $element['#field_name']; - $langcode = $element['#language']; + $locale = $element['#language']; - $field_state = field_form_get_state($parents, $field_name, $langcode, $form_state); + $field_state = field_form_get_state($parents, $field_name, $locale, $form_state); $field_state['array_parents'] = $element['#array_parents']; - field_form_set_state($parents, $field_name, $langcode, $form_state, $field_state); + field_form_set_state($parents, $field_name, $locale, $form_state, $field_state); return $element; } @@ -331,8 +331,8 @@ function field_form_element_after_build($element, &$form_state) { /** * Transfer field-level validation errors to widgets. */ -function field_default_form_errors($entity_type, $entity, $field, $instance, $langcode, $items, $form, &$form_state) { - $field_state = field_form_get_state($form['#parents'], $field['field_name'], $langcode, $form_state); +function field_default_form_errors($entity_type, $entity, $field, $instance, $locale, $items, $form, &$form_state) { + $field_state = field_form_get_state($form['#parents'], $field['field_name'], $locale, $form_state); if (!empty($field_state['errors'])) { $function = $instance['widget']['module'] . '_field_widget_error'; @@ -359,7 +359,7 @@ function field_default_form_errors($entity_type, $entity, $field, $instance, $la } // Reinitialize the errors list for the next submit. $field_state['errors'] = array(); - field_form_set_state($form['#parents'], $field['field_name'], $langcode, $form_state, $field_state); + field_form_set_state($form['#parents'], $field['field_name'], $locale, $form_state, $field_state); } } @@ -378,13 +378,13 @@ function field_add_more_submit($form, &$form_state) { // Go one level up in the form, to the widgets container. $element = drupal_array_get_nested_value($form, array_slice($button['#array_parents'], 0, -1)); $field_name = $element['#field_name']; - $langcode = $element['#language']; + $locale = $element['#language']; $parents = $element['#field_parents']; // Increment the items count. - $field_state = field_form_get_state($parents, $field_name, $langcode, $form_state); + $field_state = field_form_get_state($parents, $field_name, $locale, $form_state); $field_state['items_count']++; - field_form_set_state($parents, $field_name, $langcode, $form_state, $field_state); + field_form_set_state($parents, $field_name, $locale, $form_state, $field_state); $form_state['rebuild'] = TRUE; } @@ -403,10 +403,10 @@ function field_add_more_js($form, $form_state) { // Go one level up in the form, to the widgets container. $element = drupal_array_get_nested_value($form, array_slice($button['#array_parents'], 0, -1)); $field_name = $element['#field_name']; - $langcode = $element['#language']; + $locale = $element['#language']; $parents = $element['#field_parents']; - $field_state = field_form_get_state($parents, $field_name, $langcode, $form_state); + $field_state = field_form_get_state($parents, $field_name, $locale, $form_state); $field = $field_state['field']; if ($field['cardinality'] != FIELD_CARDINALITY_UNLIMITED) { @@ -428,7 +428,7 @@ function field_add_more_js($form, $form_state) { * The array of #parents where the field lives in the form. * @param $field_name * The field name. - * @param $langcode + * @param $locale * The language in which the field values are entered. * @param $form_state * The form state. @@ -445,8 +445,8 @@ function field_add_more_js($form, $form_state) { * * @see field_form_set_state() */ -function field_form_get_state($parents, $field_name, $langcode, &$form_state) { - $form_state_parents = _field_form_state_parents($parents, $field_name, $langcode); +function field_form_get_state($parents, $field_name, $locale, &$form_state) { + $form_state_parents = _field_form_state_parents($parents, $field_name, $locale); return drupal_array_get_nested_value($form_state, $form_state_parents); } @@ -457,7 +457,7 @@ function field_form_get_state($parents, $field_name, $langcode, &$form_state) { * The array of #parents where the field lives in the form. * @param $field_name * The field name. - * @param $langcode + * @param $locale * The language in which the field values are entered. * @param $form_state * The form state. @@ -467,15 +467,15 @@ function field_form_get_state($parents, $field_name, $langcode, &$form_state) { * * @see field_form_get_state() */ -function field_form_set_state($parents, $field_name, $langcode, &$form_state, $field_state) { - $form_state_parents = _field_form_state_parents($parents, $field_name, $langcode); +function field_form_set_state($parents, $field_name, $locale, &$form_state, $field_state) { + $form_state_parents = _field_form_state_parents($parents, $field_name, $locale); drupal_array_set_nested_value($form_state, $form_state_parents, $field_state); } /** * Returns the location of processing information within $form_state. */ -function _field_form_state_parents($parents, $field_name, $langcode) { +function _field_form_state_parents($parents, $field_name, $locale) { // To ensure backwards compatibility on regular entity forms for widgets that // still access $form_state['field'][$field_name] directly, // - top-level fields (empty $parents) are placed directly under @@ -491,7 +491,7 @@ function _field_form_state_parents($parents, $field_name, $langcode) { else { $form_state_parents = array(); } - $form_state_parents = array_merge(array('field'), $form_state_parents, array($field_name, $langcode)); + $form_state_parents = array_merge(array('field'), $form_state_parents, array($field_name, $locale)); return $form_state_parents; } diff --git a/modules/field/field.info.inc b/modules/field/field.info.inc index 6b172dd..33073ac 100644 --- a/modules/field/field.info.inc +++ b/modules/field/field.info.inc @@ -71,7 +71,7 @@ function _field_info_collate_types($reset = FALSE) { // The _info() hooks invoked below include translated strings, so each // language is cached separately. - $langcode = $language->language; + $locale = $language->language; if ($reset) { $info = NULL; @@ -81,7 +81,7 @@ function _field_info_collate_types($reset = FALSE) { } if (!isset($info)) { - if ($cached = cache_get("field_info_types:$langcode", 'cache_field')) { + if ($cached = cache_get("field_info_types:$locale", 'cache_field')) { $info = $cached->data; } else { @@ -149,7 +149,7 @@ function _field_info_collate_types($reset = FALSE) { } drupal_alter('field_storage_info', $info['storage types']); - cache_set("field_info_types:$langcode", $info, 'cache_field'); + cache_set("field_info_types:$locale", $info, 'cache_field'); } } diff --git a/modules/field/field.module b/modules/field/field.module index af9e8c8..6cd4ba3 100644 --- a/modules/field/field.module +++ b/modules/field/field.module @@ -452,15 +452,15 @@ function field_associate_fields($module) { * The field structure. * @param $instance * The instance structure. - * @param $langcode + * @param $locale * The field language to fill-in with the default value. */ -function field_get_default_value($entity_type, $entity, $field, $instance, $langcode = NULL) { +function field_get_default_value($entity_type, $entity, $field, $instance, $locale = NULL) { $items = array(); if (!empty($instance['default_value_function'])) { $function = $instance['default_value_function']; if (function_exists($function)) { - $items = $function($entity_type, $entity, $field, $instance, $langcode); + $items = $function($entity_type, $entity, $field, $instance, $locale); } } elseif (!empty($instance['default_value'])) { @@ -781,28 +781,28 @@ function _field_filter_xss_display_allowed_tags() { * The name of the field to display. * @param $item * The field value to display, as found in - * $entity->field_name[$langcode][$delta]. + * $entity->field_name[$locale][$delta]. * @param $display * Can be either the name of a view mode, or an array of display settings. * See field_view_field() for more information. - * @param $langcode + * @param $locale * (Optional) The language of the value in $item. If not provided, the * current language will be assumed. * @return * A renderable array for the field value. */ -function field_view_value($entity_type, $entity, $field_name, $item, $display = array(), $langcode = NULL) { +function field_view_value($entity_type, $entity, $field_name, $item, $display = array(), $locale = NULL) { $output = array(); if ($field = field_info_field($field_name)) { - // Determine the langcode that will be used by language fallback. - $langcode = field_language($entity_type, $entity, $field_name, $langcode); + // Determine the locale that will be used by language fallback. + $locale = field_language($entity_type, $entity, $field_name, $locale); // Push the item as the single value for the field, and defer to // field_view_field() to build the render array for the whole field. $clone = clone $entity; - $clone->{$field_name}[$langcode] = array($item); - $elements = field_view_field($entity_type, $clone, $field_name, $display, $langcode); + $clone->{$field_name}[$locale] = array($item); + $elements = field_view_field($entity_type, $clone, $field_name, $display, $locale); // Extract the part of the render array we need. $output = isset($elements[0]) ? $elements[0] : array(); @@ -859,7 +859,7 @@ function field_view_value($entity_type, $entity, $field_name, $item, $display = * hook_field_formatter_info(). * - weight: (float) The weight to assign to the renderable element. * Defaults to 0. - * @param $langcode + * @param $locale * (Optional) The language the field values are to be shown in. The site's * current language fallback logic will be applied no values are available * for the language. If no language is provided the current language will be @@ -869,7 +869,7 @@ function field_view_value($entity_type, $entity, $field_name, $item, $display = * * @see field_view_value() */ -function field_view_field($entity_type, $entity, $field_name, $display = array(), $langcode = NULL) { +function field_view_field($entity_type, $entity, $field_name, $display = array(), $locale = NULL) { $output = array(); if ($field = field_info_field($field_name)) { @@ -882,7 +882,7 @@ function field_view_field($entity_type, $entity, $field_name, $display = array() // 'single field' mode, to reuse the language fallback logic. // Determine the actual language to display for the field, given the // languages available in the field data. - $display_language = field_language($entity_type, $entity, $field_name, $langcode); + $display_language = field_language($entity_type, $entity, $field_name, $locale); $options = array('field_name' => $field_name, 'language' => $display_language); $null = NULL; @@ -926,16 +926,16 @@ function field_view_field($entity_type, $entity, $field_name, $display = array() * The entity containing the data to be displayed. * @param $field_name * The field to be displayed. - * @param $langcode + * @param $locale * (optional) The language code $entity->{$field_name} has to be displayed in. * Defaults to the current language. * * @return * An array of field items keyed by delta if available, FALSE otherwise. */ -function field_get_items($entity_type, $entity, $field_name, $langcode = NULL) { - $langcode = field_language($entity_type, $entity, $field_name, $langcode); - return isset($entity->{$field_name}[$langcode]) ? $entity->{$field_name}[$langcode] : FALSE; +function field_get_items($entity_type, $entity, $field_name, $locale = NULL) { + $locale = field_language($entity_type, $entity, $field_name, $locale); + return isset($entity->{$field_name}[$locale]) ? $entity->{$field_name}[$locale] : FALSE; } /** diff --git a/modules/field/field.multilingual.inc b/modules/field/field.multilingual.inc index 5373d97..5979f2f 100644 --- a/modules/field/field.multilingual.inc +++ b/modules/field/field.multilingual.inc @@ -13,7 +13,7 @@ * Fields natively implement multilingual support, and all fields use the * following structure: * @code - * $entity->{$field_name}[$langcode][$delta][$column_name] + * $entity->{$field_name}[$locale][$delta][$column_name] * @endcode * Every field can hold a single or multiple value for each language belonging * to the available languages set: @@ -214,18 +214,18 @@ function field_has_translation_handler($entity_type, $handler = NULL) { * it returns the current, global language; or the site's default language, if * the additional parameter $default is TRUE. * - * @param $langcode + * @param $locale * The language code to validate. * @param $default * Whether to return the default language code or the current language code in - * case $langcode is invalid. + * case $locale is invalid. * @return * A valid language code. */ -function field_valid_language($langcode, $default = TRUE) { +function field_valid_language($locale, $default = TRUE) { $enabled_languages = field_content_languages(); - if (in_array($langcode, $enabled_languages)) { - return $langcode; + if (in_array($locale, $enabled_languages)) { + return $locale; } global $language_content; return $default ? language_default('language') : $language_content->language; @@ -252,7 +252,7 @@ function field_valid_language($langcode, $default = TRUE) { * (optional) The name of the field to be displayed. Defaults to NULL. If * no value is specified, the display languages for every field attached to * the given entity will be returned. - * @param $langcode + * @param $locale * (optional) The language code $entity has to be displayed in. Defaults to * NULL. If no value is given the current language will be used. * @@ -260,34 +260,34 @@ function field_valid_language($langcode, $default = TRUE) { * A language code if a field name is specified, an array of language codes * keyed by field name otherwise. */ -function field_language($entity_type, $entity, $field_name = NULL, $langcode = NULL) { +function field_language($entity_type, $entity, $field_name = NULL, $locale = NULL) { $display_languages = &drupal_static(__FUNCTION__, array()); list($id, , $bundle) = entity_extract_ids($entity_type, $entity); - $langcode = field_valid_language($langcode, FALSE); + $locale = field_valid_language($locale, FALSE); - if (!isset($display_languages[$entity_type][$id][$langcode])) { + if (!isset($display_languages[$entity_type][$id][$locale])) { $display_language = array(); // By default display language is set to LANGUAGE_NONE if the field // translation is not available. It is up to translation handlers to // implement language fallback rules. foreach (field_info_instances($entity_type, $bundle) as $instance) { - $display_language[$instance['field_name']] = isset($entity->{$instance['field_name']}[$langcode]) ? $langcode : LANGUAGE_NONE; + $display_language[$instance['field_name']] = isset($entity->{$instance['field_name']}[$locale]) ? $locale : LANGUAGE_NONE; } if (field_has_translation_handler($entity_type)) { $context = array( 'entity_type' => $entity_type, 'entity' => $entity, - 'language' => $langcode, + 'language' => $locale, ); drupal_alter('field_language', $display_language, $context); } - $display_languages[$entity_type][$id][$langcode] = $display_language; + $display_languages[$entity_type][$id][$locale] = $display_language; } - $display_language = $display_languages[$entity_type][$id][$langcode]; + $display_language = $display_languages[$entity_type][$id][$locale]; // Single-field mode. if (isset($field_name)) { diff --git a/modules/field/modules/field_sql_storage/field_sql_storage.install b/modules/field/modules/field_sql_storage/field_sql_storage.install index 4a3a00e..95bdbfc 100644 --- a/modules/field/modules/field_sql_storage/field_sql_storage.install +++ b/modules/field/modules/field_sql_storage/field_sql_storage.install @@ -44,7 +44,7 @@ function _update_7000_field_sql_storage_write($entity_type, $bundle, $entity_id, ->execute(); $columns = array(); - foreach ($data as $langcode => $items) { + foreach ($data as $locale => $items) { foreach ($items as $delta => $item) { $record = array( 'entity_type' => $entity_type, @@ -52,7 +52,7 @@ function _update_7000_field_sql_storage_write($entity_type, $bundle, $entity_id, 'revision_id' => $revision_id, 'bundle' => $bundle, 'delta' => $delta, - 'language' => $langcode, + 'language' => $locale, ); foreach ($item as $column => $value) { $record[_field_sql_storage_columnname($field_name, $column)] = $value; diff --git a/modules/field/modules/field_sql_storage/field_sql_storage.module b/modules/field/modules/field_sql_storage/field_sql_storage.module index 6f49167..05b12b0 100644 --- a/modules/field/modules/field_sql_storage/field_sql_storage.module +++ b/modules/field/modules/field_sql_storage/field_sql_storage.module @@ -391,8 +391,8 @@ function field_sql_storage_field_storage_write($entity_type, $entity, $op, $fiel $query = db_insert($table_name)->fields($columns); $revision_query = db_insert($revision_name)->fields($columns); - foreach ($field_languages as $langcode) { - $items = (array) $entity->{$field_name}[$langcode]; + foreach ($field_languages as $locale) { + $items = (array) $entity->{$field_name}[$locale]; $delta_count = 0; foreach ($items as $delta => $item) { // We now know we have someting to insert. @@ -403,7 +403,7 @@ function field_sql_storage_field_storage_write($entity_type, $entity, $op, $fiel 'revision_id' => $vid, 'bundle' => $bundle, 'delta' => $delta, - 'language' => $langcode, + 'language' => $locale, ); foreach ($field['columns'] as $column => $attributes) { $record[_field_sql_storage_columnname($field_name, $column)] = isset($item[$column]) ? $item[$column] : NULL; diff --git a/modules/field/modules/field_sql_storage/field_sql_storage.test b/modules/field/modules/field_sql_storage/field_sql_storage.test index f94344f..8804e70 100644 --- a/modules/field/modules/field_sql_storage/field_sql_storage.test +++ b/modules/field/modules/field_sql_storage/field_sql_storage.test @@ -43,7 +43,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { function testFieldAttachLoad() { $entity_type = 'test_entity'; $eid = 0; - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $columns = array('entity_type', 'entity_id', 'revision_id', 'delta', 'language', $this->field_name . '_value'); @@ -55,7 +55,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { for ($delta = 0; $delta <= $this->field['cardinality']; $delta++) { $value = mt_rand(1, 127); $values[$evid][] = $value; - $query->values(array($entity_type, $eid, $evid, $delta, $langcode, $value)); + $query->values(array($entity_type, $eid, $evid, $delta, $locale, $value)); } } $query->execute(); @@ -63,7 +63,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { // Insert data for the "most current revision" into the field table $query = db_insert($this->table)->fields($columns); foreach ($values[0] as $delta => $value) { - $query->values(array($entity_type, $eid, 0, $delta, $langcode, $value)); + $query->values(array($entity_type, $eid, 0, $delta, $locale, $value)); } $query->execute(); @@ -72,10 +72,10 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { field_attach_load($entity_type, array($eid => $entity)); foreach ($values[0] as $delta => $value) { if ($delta < $this->field['cardinality']) { - $this->assertEqual($entity->{$this->field_name}[$langcode][$delta]['value'], $value, "Value $delta is loaded correctly for current revision"); + $this->assertEqual($entity->{$this->field_name}[$locale][$delta]['value'], $value, "Value $delta is loaded correctly for current revision"); } else { - $this->assertFalse(array_key_exists($delta, $entity->{$this->field_name}[$langcode]), "No extraneous value gets loaded for current revision."); + $this->assertFalse(array_key_exists($delta, $entity->{$this->field_name}[$locale]), "No extraneous value gets loaded for current revision."); } } @@ -85,10 +85,10 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { field_attach_load_revision($entity_type, array($eid => $entity)); foreach ($values[$evid] as $delta => $value) { if ($delta < $this->field['cardinality']) { - $this->assertEqual($entity->{$this->field_name}[$langcode][$delta]['value'], $value, "Value $delta for revision $evid is loaded correctly"); + $this->assertEqual($entity->{$this->field_name}[$locale][$delta]['value'], $value, "Value $delta for revision $evid is loaded correctly"); } else { - $this->assertFalse(array_key_exists($delta, $entity->{$this->field_name}[$langcode]), "No extraneous value gets loaded for revision $evid."); + $this->assertFalse(array_key_exists($delta, $entity->{$this->field_name}[$locale]), "No extraneous value gets loaded for revision $evid."); } } } @@ -111,7 +111,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { function testFieldAttachInsertAndUpdate() { $entity_type = 'test_entity'; $entity = field_test_create_stub_entity(0, 0, $this->instance['bundle']); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // Test insert. $values = array(); @@ -120,7 +120,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { for ($delta = 0; $delta <= $this->field['cardinality']; $delta++) { $values[$delta]['value'] = mt_rand(1, 127); } - $entity->{$this->field_name}[$langcode] = $rev_values[0] = $values; + $entity->{$this->field_name}[$locale] = $rev_values[0] = $values; field_attach_insert($entity_type, $entity); $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC); @@ -140,7 +140,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { for ($delta = 0; $delta <= $this->field['cardinality']; $delta++) { $values[$delta]['value'] = mt_rand(1, 127); } - $entity->{$this->field_name}[$langcode] = $rev_values[1] = $values; + $entity->{$this->field_name}[$locale] = $rev_values[1] = $values; field_attach_update($entity_type, $entity); $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC); foreach ($values as $delta => $value) { @@ -192,7 +192,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { function testFieldAttachSaveMissingData() { $entity_type = 'test_entity'; $entity = field_test_create_stub_entity(0, 0, $this->instance['bundle']); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // Insert: Field is missing field_attach_insert($entity_type, $entity); @@ -212,7 +212,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { $this->assertEqual($count, 0, 'NULL field results in no inserts'); // Add some real data - $entity->{$this->field_name}[$langcode] = array(0 => array('value' => 1)); + $entity->{$this->field_name}[$locale] = array(0 => array('value' => 1)); field_attach_insert($entity_type, $entity); $count = db_select($this->table) ->countQuery() @@ -251,7 +251,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { $this->assertEqual($count, 1, 'Field translation in an unavailable language saved.'); // Again add some real data. - $entity->{$this->field_name}[$langcode] = array(0 => array('value' => 1)); + $entity->{$this->field_name}[$locale] = array(0 => array('value' => 1)); field_attach_insert($entity_type, $entity); $count = db_select($this->table) ->countQuery() @@ -262,7 +262,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { // Update: Field translation is missing but field is not empty. Translation // data should survive. $entity->{$this->field_name}[$unavailable_language] = array(mt_rand(1, 127)); - unset($entity->{$this->field_name}[$langcode]); + unset($entity->{$this->field_name}[$locale]); field_attach_update($entity_type, $entity); $count = db_select($this->table) ->countQuery() @@ -272,7 +272,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { // Update: Field translation is NULL but field is not empty. Translation // data should be wiped. - $entity->{$this->field_name}[$langcode] = NULL; + $entity->{$this->field_name}[$locale] = NULL; field_attach_update($entity_type, $entity); $count = db_select($this->table) ->countQuery() diff --git a/modules/field/modules/list/list.module b/modules/field/modules/list/list.module index 2518ebc..045ad08 100644 --- a/modules/field/modules/list/list.module +++ b/modules/field/modules/list/list.module @@ -372,12 +372,12 @@ function _list_values_in_use($field, $values) { * Possible error codes: * - 'list_illegal_value': The value is not part of the list of allowed values. */ -function list_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) { +function list_field_validate($entity_type, $entity, $field, $instance, $locale, $items, &$errors) { $allowed_values = list_allowed_values($field); foreach ($items as $delta => $item) { if (!empty($item['value'])) { if (!empty($allowed_values) && !isset($allowed_values[$item['value']])) { - $errors[$field['field_name']][$langcode][$delta][] = array( + $errors[$field['field_name']][$locale][$delta][] = array( 'error' => 'list_illegal_value', 'message' => t('%name: illegal value.', array('%name' => $instance['label'])), ); @@ -442,7 +442,7 @@ function list_field_formatter_info() { /** * Implements hook_field_formatter_view(). */ -function list_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { +function list_field_formatter_view($entity_type, $entity, $field, $instance, $locale, $items, $display) { $element = array(); switch ($display['type']) { diff --git a/modules/field/modules/list/tests/list.test b/modules/field/modules/list/tests/list.test index dec0956..08877a3 100644 --- a/modules/field/modules/list/tests/list.test +++ b/modules/field/modules/list/tests/list.test @@ -46,19 +46,19 @@ class ListFieldTestCase extends FieldTestCase { * Test that allowed values can be updated. */ function testUpdateAllowedValues() { - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // All three options appear. $entity = field_test_create_stub_entity(); $form = drupal_get_form('field_test_entity_form', $entity); - $this->assertTrue(!empty($form[$this->field_name][$langcode][1]), t('Option 1 exists')); - $this->assertTrue(!empty($form[$this->field_name][$langcode][2]), t('Option 2 exists')); - $this->assertTrue(!empty($form[$this->field_name][$langcode][3]), t('Option 3 exists')); + $this->assertTrue(!empty($form[$this->field_name][$locale][1]), t('Option 1 exists')); + $this->assertTrue(!empty($form[$this->field_name][$locale][2]), t('Option 2 exists')); + $this->assertTrue(!empty($form[$this->field_name][$locale][3]), t('Option 3 exists')); // Use one of the values in an actual entity, and check that this value // cannot be removed from the list. $entity = field_test_create_stub_entity(); - $entity->{$this->field_name}[$langcode][0] = array('value' => 1); + $entity->{$this->field_name}[$locale][0] = array('value' => 1); field_test_entity_save($entity); $this->field['settings']['allowed_values'] = array(2 => 'Two'); try { @@ -69,7 +69,7 @@ class ListFieldTestCase extends FieldTestCase { $this->pass(t('Cannot update a list field to not include keys with existing data.')); } // Empty the value, so that we can actually remove the option. - $entity->{$this->field_name}[$langcode] = array(); + $entity->{$this->field_name}[$locale] = array(); field_test_entity_save($entity); // Removed options do not appear. @@ -77,19 +77,19 @@ class ListFieldTestCase extends FieldTestCase { field_update_field($this->field); $entity = field_test_create_stub_entity(); $form = drupal_get_form('field_test_entity_form', $entity); - $this->assertTrue(empty($form[$this->field_name][$langcode][1]), t('Option 1 does not exist')); - $this->assertTrue(!empty($form[$this->field_name][$langcode][2]), t('Option 2 exists')); - $this->assertTrue(empty($form[$this->field_name][$langcode][3]), t('Option 3 does not exist')); + $this->assertTrue(empty($form[$this->field_name][$locale][1]), t('Option 1 does not exist')); + $this->assertTrue(!empty($form[$this->field_name][$locale][2]), t('Option 2 exists')); + $this->assertTrue(empty($form[$this->field_name][$locale][3]), t('Option 3 does not exist')); // Completely new options appear. $this->field['settings']['allowed_values'] = array(10 => 'Update', 20 => 'Twenty'); field_update_field($this->field); $form = drupal_get_form('field_test_entity_form', $entity); - $this->assertTrue(empty($form[$this->field_name][$langcode][1]), t('Option 1 does not exist')); - $this->assertTrue(empty($form[$this->field_name][$langcode][2]), t('Option 2 does not exist')); - $this->assertTrue(empty($form[$this->field_name][$langcode][3]), t('Option 3 does not exist')); - $this->assertTrue(!empty($form[$this->field_name][$langcode][10]), t('Option 10 exists')); - $this->assertTrue(!empty($form[$this->field_name][$langcode][20]), t('Option 20 exists')); + $this->assertTrue(empty($form[$this->field_name][$locale][1]), t('Option 1 does not exist')); + $this->assertTrue(empty($form[$this->field_name][$locale][2]), t('Option 2 does not exist')); + $this->assertTrue(empty($form[$this->field_name][$locale][3]), t('Option 3 does not exist')); + $this->assertTrue(!empty($form[$this->field_name][$locale][10]), t('Option 10 exists')); + $this->assertTrue(!empty($form[$this->field_name][$locale][20]), t('Option 20 exists')); // Options are reset when a new field with the same name is created. field_delete_field($this->field_name); @@ -107,9 +107,9 @@ class ListFieldTestCase extends FieldTestCase { $this->instance = field_create_instance($this->instance); $entity = field_test_create_stub_entity(); $form = drupal_get_form('field_test_entity_form', $entity); - $this->assertTrue(!empty($form[$this->field_name][$langcode][1]), t('Option 1 exists')); - $this->assertTrue(!empty($form[$this->field_name][$langcode][2]), t('Option 2 exists')); - $this->assertTrue(!empty($form[$this->field_name][$langcode][3]), t('Option 3 exists')); + $this->assertTrue(!empty($form[$this->field_name][$locale][1]), t('Option 1 exists')); + $this->assertTrue(!empty($form[$this->field_name][$locale][2]), t('Option 2 exists')); + $this->assertTrue(!empty($form[$this->field_name][$locale][3]), t('Option 3 exists')); } } diff --git a/modules/field/modules/number/number.module b/modules/field/modules/number/number.module index 3c8132c..540dc75 100644 --- a/modules/field/modules/number/number.module +++ b/modules/field/modules/number/number.module @@ -132,17 +132,17 @@ function number_field_instance_settings_form($field, $instance) { * - 'number_min': The value is less than the allowed minimum value. * - 'number_max': The value is greater than the allowed maximum value. */ -function number_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) { +function number_field_validate($entity_type, $entity, $field, $instance, $locale, $items, &$errors) { foreach ($items as $delta => $item) { if ($item['value'] != '') { if (is_numeric($instance['settings']['min']) && $item['value'] < $instance['settings']['min']) { - $errors[$field['field_name']][$langcode][$delta][] = array( + $errors[$field['field_name']][$locale][$delta][] = array( 'error' => 'number_min', 'message' => t('%name: the value may be no less than %min.', array('%name' => $instance['label'], '%min' => $instance['settings']['min'])), ); } if (is_numeric($instance['settings']['max']) && $item['value'] > $instance['settings']['max']) { - $errors[$field['field_name']][$langcode][$delta][] = array( + $errors[$field['field_name']][$locale][$delta][] = array( 'error' => 'number_max', 'message' => t('%name: the value may be no greater than %max.', array('%name' => $instance['label'], '%max' => $instance['settings']['max'])), ); @@ -154,7 +154,7 @@ function number_field_validate($entity_type, $entity, $field, $instance, $langco /** * Implements hook_field_presave(). */ -function number_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) { +function number_field_presave($entity_type, $entity, $field, $instance, $locale, &$items) { if ($field['type'] == 'number_decimal') { // Let PHP round the value to ensure consistent behavior across storage // backends. @@ -272,7 +272,7 @@ function number_field_formatter_settings_summary($field, $instance, $view_mode) /** * Implements hook_field_formatter_view(). */ -function number_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { +function number_field_formatter_view($entity_type, $entity, $field, $instance, $locale, $items, $display) { $element = array(); $settings = $display['settings']; @@ -317,7 +317,7 @@ function number_field_widget_info() { /** * Implements hook_field_widget_form(). */ -function number_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) { +function number_field_widget_form(&$form, &$form_state, $field, $instance, $locale, $items, $delta, $element) { $value = isset($items[$delta]['value']) ? $items[$delta]['value'] : ''; // Substitute the decimal separator. if ($field['type'] == 'number_decimal' || $field['type'] == 'number_float') { diff --git a/modules/field/modules/number/number.test b/modules/field/modules/number/number.test index 3b0cbaf..5273f03 100644 --- a/modules/field/modules/number/number.test +++ b/modules/field/modules/number/number.test @@ -57,13 +57,13 @@ class NumberFieldTestCase extends DrupalWebTestCase { // Display creation form. $this->drupalGet('test-entity/add/test-bundle'); - $langcode = LANGUAGE_NONE; - $this->assertFieldByName("{$this->field['field_name']}[$langcode][0][value]", '', t('Widget is displayed')); + $locale = LANGUAGE_NONE; + $this->assertFieldByName("{$this->field['field_name']}[$locale][0][value]", '', t('Widget is displayed')); // Submit a signed decimal value within the allowed precision and scale. $value = '-1234.5678'; $edit = array( - "{$this->field['field_name']}[$langcode][0][value]" => $value, + "{$this->field['field_name']}[$locale][0][value]" => $value, ); $this->drupalPost(NULL, $edit, t('Save')); preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match); @@ -83,7 +83,7 @@ class NumberFieldTestCase extends DrupalWebTestCase { foreach ($wrong_entries as $wrong_entry) { $this->drupalGet('test-entity/add/test-bundle'); $edit = array( - "{$this->field['field_name']}[$langcode][0][value]" => $wrong_entry, + "{$this->field['field_name']}[$locale][0][value]" => $wrong_entry, ); $this->drupalPost(NULL, $edit, t('Save')); $this->assertText( diff --git a/modules/field/modules/options/options.module b/modules/field/modules/options/options.module index 385f3f4..4c8e3d3 100644 --- a/modules/field/modules/options/options.module +++ b/modules/field/modules/options/options.module @@ -68,7 +68,7 @@ function options_field_widget_info() { /** * Implements hook_field_widget_form(). */ -function options_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) { +function options_field_widget_form(&$form, &$form_state, $field, $instance, $locale, $items, $delta, $element) { // Abstract over the actual field columns, to allow different field types to // reuse those widgets. $value_key = key($field['columns']); diff --git a/modules/field/modules/options/options.test b/modules/field/modules/options/options.test index ea58f27..69bf57f 100644 --- a/modules/field/modules/options/options.test +++ b/modules/field/modules/options/options.test @@ -72,7 +72,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { ), ); $instance = field_create_instance($instance); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // Create an entity. $entity_init = field_test_create_stub_entity(); @@ -82,26 +82,26 @@ class OptionsWidgetsTestCase extends FieldTestCase { // With no field data, no buttons are checked. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); - $this->assertNoFieldChecked("edit-card-1-$langcode-0"); - $this->assertNoFieldChecked("edit-card-1-$langcode-1"); - $this->assertNoFieldChecked("edit-card-1-$langcode-2"); + $this->assertNoFieldChecked("edit-card-1-$locale-0"); + $this->assertNoFieldChecked("edit-card-1-$locale-1"); + $this->assertNoFieldChecked("edit-card-1-$locale-2"); $this->assertRaw('Some dangerous & unescaped markup', t('Option text was properly filtered.')); // Select first option. - $edit = array("card_1[$langcode]" => 0); + $edit = array("card_1[$locale]" => 0); $this->drupalPost(NULL, $edit, t('Save')); - $this->assertFieldValues($entity_init, 'card_1', $langcode, array(0)); + $this->assertFieldValues($entity_init, 'card_1', $locale, array(0)); // Check that the selected button is checked. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); - $this->assertFieldChecked("edit-card-1-$langcode-0"); - $this->assertNoFieldChecked("edit-card-1-$langcode-1"); - $this->assertNoFieldChecked("edit-card-1-$langcode-2"); + $this->assertFieldChecked("edit-card-1-$locale-0"); + $this->assertNoFieldChecked("edit-card-1-$locale-1"); + $this->assertNoFieldChecked("edit-card-1-$locale-2"); // Unselect option. - $edit = array("card_1[$langcode]" => '_none'); + $edit = array("card_1[$locale]" => '_none'); $this->drupalPost(NULL, $edit, t('Save')); - $this->assertFieldValues($entity_init, 'card_1', $langcode, array()); + $this->assertFieldValues($entity_init, 'card_1', $locale, array()); // Check that required radios with one option is auto-selected. $this->card_1['settings']['allowed_values'] = array(99 => 'Only allowed value'); @@ -109,7 +109,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { $instance['required'] = TRUE; field_update_instance($instance); $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); - $this->assertFieldChecked("edit-card-1-$langcode-99"); + $this->assertFieldChecked("edit-card-1-$locale-99"); } /** @@ -126,7 +126,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { ), ); $instance = field_create_instance($instance); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // Create an entity. $entity_init = field_test_create_stub_entity(); @@ -136,59 +136,59 @@ class OptionsWidgetsTestCase extends FieldTestCase { // Display form: with no field data, nothing is checked. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); - $this->assertNoFieldChecked("edit-card-2-$langcode-0"); - $this->assertNoFieldChecked("edit-card-2-$langcode-1"); - $this->assertNoFieldChecked("edit-card-2-$langcode-2"); + $this->assertNoFieldChecked("edit-card-2-$locale-0"); + $this->assertNoFieldChecked("edit-card-2-$locale-1"); + $this->assertNoFieldChecked("edit-card-2-$locale-2"); $this->assertRaw('Some dangerous & unescaped markup', t('Option text was properly filtered.')); // Submit form: select first and third options. $edit = array( - "card_2[$langcode][0]" => TRUE, - "card_2[$langcode][1]" => FALSE, - "card_2[$langcode][2]" => TRUE, + "card_2[$locale][0]" => TRUE, + "card_2[$locale][1]" => FALSE, + "card_2[$locale][2]" => TRUE, ); $this->drupalPost(NULL, $edit, t('Save')); - $this->assertFieldValues($entity_init, 'card_2', $langcode, array(0, 2)); + $this->assertFieldValues($entity_init, 'card_2', $locale, array(0, 2)); // Display form: check that the right options are selected. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); - $this->assertFieldChecked("edit-card-2-$langcode-0"); - $this->assertNoFieldChecked("edit-card-2-$langcode-1"); - $this->assertFieldChecked("edit-card-2-$langcode-2"); + $this->assertFieldChecked("edit-card-2-$locale-0"); + $this->assertNoFieldChecked("edit-card-2-$locale-1"); + $this->assertFieldChecked("edit-card-2-$locale-2"); // Submit form: select only first option. $edit = array( - "card_2[$langcode][0]" => TRUE, - "card_2[$langcode][1]" => FALSE, - "card_2[$langcode][2]" => FALSE, + "card_2[$locale][0]" => TRUE, + "card_2[$locale][1]" => FALSE, + "card_2[$locale][2]" => FALSE, ); $this->drupalPost(NULL, $edit, t('Save')); - $this->assertFieldValues($entity_init, 'card_2', $langcode, array(0)); + $this->assertFieldValues($entity_init, 'card_2', $locale, array(0)); // Display form: check that the right options are selected. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); - $this->assertFieldChecked("edit-card-2-$langcode-0"); - $this->assertNoFieldChecked("edit-card-2-$langcode-1"); - $this->assertNoFieldChecked("edit-card-2-$langcode-2"); + $this->assertFieldChecked("edit-card-2-$locale-0"); + $this->assertNoFieldChecked("edit-card-2-$locale-1"); + $this->assertNoFieldChecked("edit-card-2-$locale-2"); // Submit form: select the three options while the field accepts only 2. $edit = array( - "card_2[$langcode][0]" => TRUE, - "card_2[$langcode][1]" => TRUE, - "card_2[$langcode][2]" => TRUE, + "card_2[$locale][0]" => TRUE, + "card_2[$locale][1]" => TRUE, + "card_2[$locale][2]" => TRUE, ); $this->drupalPost(NULL, $edit, t('Save')); $this->assertText('this field cannot hold more than 2 values', t('Validation error was displayed.')); // Submit form: uncheck all options. $edit = array( - "card_2[$langcode][0]" => FALSE, - "card_2[$langcode][1]" => FALSE, - "card_2[$langcode][2]" => FALSE, + "card_2[$locale][0]" => FALSE, + "card_2[$locale][1]" => FALSE, + "card_2[$locale][2]" => FALSE, ); $this->drupalPost(NULL, $edit, t('Save')); // Check that the value was saved. - $this->assertFieldValues($entity_init, 'card_2', $langcode, array()); + $this->assertFieldValues($entity_init, 'card_2', $locale, array()); // Required checkbox with one option is auto-selected. $this->card_2['settings']['allowed_values'] = array(99 => 'Only allowed value'); @@ -196,7 +196,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { $instance['required'] = TRUE; field_update_instance($instance); $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); - $this->assertFieldChecked("edit-card-2-$langcode-99"); + $this->assertFieldChecked("edit-card-2-$locale-99"); } /** @@ -214,7 +214,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { ), ); $instance = field_create_instance($instance); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // Create an entity. $entity_init = field_test_create_stub_entity(); @@ -225,32 +225,32 @@ class OptionsWidgetsTestCase extends FieldTestCase { // Display form. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); // A required field without any value has a "none" option. - $this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', array(':id' => 'edit-card-1-' . $langcode, ':label' => t('- Select a value -'))), t('A required select list has a "Select a value" choice.')); + $this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', array(':id' => 'edit-card-1-' . $locale, ':label' => t('- Select a value -'))), t('A required select list has a "Select a value" choice.')); // With no field data, nothing is selected. - $this->assertNoOptionSelected("edit-card-1-$langcode", '_none'); - $this->assertNoOptionSelected("edit-card-1-$langcode", 0); - $this->assertNoOptionSelected("edit-card-1-$langcode", 1); - $this->assertNoOptionSelected("edit-card-1-$langcode", 2); + $this->assertNoOptionSelected("edit-card-1-$locale", '_none'); + $this->assertNoOptionSelected("edit-card-1-$locale", 0); + $this->assertNoOptionSelected("edit-card-1-$locale", 1); + $this->assertNoOptionSelected("edit-card-1-$locale", 2); $this->assertRaw('Some dangerous & unescaped markup', t('Option text was properly filtered.')); // Submit form: select invalid 'none' option. - $edit = array("card_1[$langcode]" => '_none'); + $edit = array("card_1[$locale]" => '_none'); $this->drupalPost(NULL, $edit, t('Save')); $this->assertRaw(t('!title field is required.', array('!title' => $instance['field_name'])), t('Cannot save a required field when selecting "none" from the select list.')); // Submit form: select first option. - $edit = array("card_1[$langcode]" => 0); + $edit = array("card_1[$locale]" => 0); $this->drupalPost(NULL, $edit, t('Save')); - $this->assertFieldValues($entity_init, 'card_1', $langcode, array(0)); + $this->assertFieldValues($entity_init, 'card_1', $locale, array(0)); // Display form: check that the right options are selected. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); // A required field with a value has no 'none' option. - $this->assertFalse($this->xpath('//select[@id=:id]//option[@value="_none"]', array(':id' => 'edit-card-1-' . $langcode)), t('A required select list with an actual value has no "none" choice.')); - $this->assertOptionSelected("edit-card-1-$langcode", 0); - $this->assertNoOptionSelected("edit-card-1-$langcode", 1); - $this->assertNoOptionSelected("edit-card-1-$langcode", 2); + $this->assertFalse($this->xpath('//select[@id=:id]//option[@value="_none"]', array(':id' => 'edit-card-1-' . $locale)), t('A required select list with an actual value has no "none" choice.')); + $this->assertOptionSelected("edit-card-1-$locale", 0); + $this->assertNoOptionSelected("edit-card-1-$locale", 1); + $this->assertNoOptionSelected("edit-card-1-$locale", 2); // Make the field non required. $instance['required'] = FALSE; @@ -259,11 +259,11 @@ class OptionsWidgetsTestCase extends FieldTestCase { // Display form. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); // A non-required field has a 'none' option. - $this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', array(':id' => 'edit-card-1-' . $langcode, ':label' => t('- None -'))), t('A non-required select list has a "None" choice.')); + $this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', array(':id' => 'edit-card-1-' . $locale, ':label' => t('- None -'))), t('A non-required select list has a "None" choice.')); // Submit form: Unselect the option. - $edit = array("card_1[$langcode]" => '_none'); + $edit = array("card_1[$locale]" => '_none'); $this->drupalPost('test-entity/manage/' . $entity->ftid . '/edit', $edit, t('Save')); - $this->assertFieldValues($entity_init, 'card_1', $langcode, array()); + $this->assertFieldValues($entity_init, 'card_1', $locale, array()); // Test optgroups. @@ -273,27 +273,27 @@ class OptionsWidgetsTestCase extends FieldTestCase { // Display form: with no field data, nothing is selected $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); - $this->assertNoOptionSelected("edit-card-1-$langcode", 0); - $this->assertNoOptionSelected("edit-card-1-$langcode", 1); - $this->assertNoOptionSelected("edit-card-1-$langcode", 2); + $this->assertNoOptionSelected("edit-card-1-$locale", 0); + $this->assertNoOptionSelected("edit-card-1-$locale", 1); + $this->assertNoOptionSelected("edit-card-1-$locale", 2); $this->assertRaw('Some dangerous & unescaped markup', t('Option text was properly filtered.')); $this->assertRaw('Group 1', t('Option groups are displayed.')); // Submit form: select first option. - $edit = array("card_1[$langcode]" => 0); + $edit = array("card_1[$locale]" => 0); $this->drupalPost(NULL, $edit, t('Save')); - $this->assertFieldValues($entity_init, 'card_1', $langcode, array(0)); + $this->assertFieldValues($entity_init, 'card_1', $locale, array(0)); // Display form: check that the right options are selected. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); - $this->assertOptionSelected("edit-card-1-$langcode", 0); - $this->assertNoOptionSelected("edit-card-1-$langcode", 1); - $this->assertNoOptionSelected("edit-card-1-$langcode", 2); + $this->assertOptionSelected("edit-card-1-$locale", 0); + $this->assertNoOptionSelected("edit-card-1-$locale", 1); + $this->assertNoOptionSelected("edit-card-1-$locale", 2); // Submit form: Unselect the option. - $edit = array("card_1[$langcode]" => '_none'); + $edit = array("card_1[$locale]" => '_none'); $this->drupalPost('test-entity/manage/' . $entity->ftid . '/edit', $edit, t('Save')); - $this->assertFieldValues($entity_init, 'card_1', $langcode, array()); + $this->assertFieldValues($entity_init, 'card_1', $locale, array()); } /** @@ -310,7 +310,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { ), ); $instance = field_create_instance($instance); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // Create an entity. $entity_init = field_test_create_stub_entity(); @@ -320,61 +320,61 @@ class OptionsWidgetsTestCase extends FieldTestCase { // Display form: with no field data, nothing is selected. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); - $this->assertNoOptionSelected("edit-card-2-$langcode", 0); - $this->assertNoOptionSelected("edit-card-2-$langcode", 1); - $this->assertNoOptionSelected("edit-card-2-$langcode", 2); + $this->assertNoOptionSelected("edit-card-2-$locale", 0); + $this->assertNoOptionSelected("edit-card-2-$locale", 1); + $this->assertNoOptionSelected("edit-card-2-$locale", 2); $this->assertRaw('Some dangerous & unescaped markup', t('Option text was properly filtered.')); // Submit form: select first and third options. - $edit = array("card_2[$langcode][]" => array(0 => 0, 2 => 2)); + $edit = array("card_2[$locale][]" => array(0 => 0, 2 => 2)); $this->drupalPost(NULL, $edit, t('Save')); - $this->assertFieldValues($entity_init, 'card_2', $langcode, array(0, 2)); + $this->assertFieldValues($entity_init, 'card_2', $locale, array(0, 2)); // Display form: check that the right options are selected. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); - $this->assertOptionSelected("edit-card-2-$langcode", 0); - $this->assertNoOptionSelected("edit-card-2-$langcode", 1); - $this->assertOptionSelected("edit-card-2-$langcode", 2); + $this->assertOptionSelected("edit-card-2-$locale", 0); + $this->assertNoOptionSelected("edit-card-2-$locale", 1); + $this->assertOptionSelected("edit-card-2-$locale", 2); // Submit form: select only first option. - $edit = array("card_2[$langcode][]" => array(0 => 0)); + $edit = array("card_2[$locale][]" => array(0 => 0)); $this->drupalPost(NULL, $edit, t('Save')); - $this->assertFieldValues($entity_init, 'card_2', $langcode, array(0)); + $this->assertFieldValues($entity_init, 'card_2', $locale, array(0)); // Display form: check that the right options are selected. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); - $this->assertOptionSelected("edit-card-2-$langcode", 0); - $this->assertNoOptionSelected("edit-card-2-$langcode", 1); - $this->assertNoOptionSelected("edit-card-2-$langcode", 2); + $this->assertOptionSelected("edit-card-2-$locale", 0); + $this->assertNoOptionSelected("edit-card-2-$locale", 1); + $this->assertNoOptionSelected("edit-card-2-$locale", 2); // Submit form: select the three options while the field accepts only 2. - $edit = array("card_2[$langcode][]" => array(0 => 0, 1 => 1, 2 => 2)); + $edit = array("card_2[$locale][]" => array(0 => 0, 1 => 1, 2 => 2)); $this->drupalPost(NULL, $edit, t('Save')); $this->assertText('this field cannot hold more than 2 values', t('Validation error was displayed.')); // Submit form: uncheck all options. - $edit = array("card_2[$langcode][]" => array()); + $edit = array("card_2[$locale][]" => array()); $this->drupalPost(NULL, $edit, t('Save')); - $this->assertFieldValues($entity_init, 'card_2', $langcode, array()); + $this->assertFieldValues($entity_init, 'card_2', $locale, array()); // Test the 'None' option. // Check that the 'none' option has no efect if actual options are selected // as well. - $edit = array("card_2[$langcode][]" => array('_none' => '_none', 0 => 0)); + $edit = array("card_2[$locale][]" => array('_none' => '_none', 0 => 0)); $this->drupalPost('test-entity/manage/' . $entity->ftid . '/edit', $edit, t('Save')); - $this->assertFieldValues($entity_init, 'card_2', $langcode, array(0)); + $this->assertFieldValues($entity_init, 'card_2', $locale, array(0)); // Check that selecting the 'none' option empties the field. - $edit = array("card_2[$langcode][]" => array('_none' => '_none')); + $edit = array("card_2[$locale][]" => array('_none' => '_none')); $this->drupalPost('test-entity/manage/' . $entity->ftid . '/edit', $edit, t('Save')); - $this->assertFieldValues($entity_init, 'card_2', $langcode, array()); + $this->assertFieldValues($entity_init, 'card_2', $locale, array()); // A required select list does not have an empty key. $instance['required'] = TRUE; field_update_instance($instance); $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); - $this->assertFalse($this->xpath('//select[@id=:id]//option[@value=""]', array(':id' => 'edit-card-2-' . $langcode)), t('A required select list does not have an empty key.')); + $this->assertFalse($this->xpath('//select[@id=:id]//option[@value=""]', array(':id' => 'edit-card-2-' . $locale)), t('A required select list does not have an empty key.')); // We do not have to test that a required select list with one option is // auto-selected because the browser does it for us. @@ -390,27 +390,27 @@ class OptionsWidgetsTestCase extends FieldTestCase { // Display form: with no field data, nothing is selected. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); - $this->assertNoOptionSelected("edit-card-2-$langcode", 0); - $this->assertNoOptionSelected("edit-card-2-$langcode", 1); - $this->assertNoOptionSelected("edit-card-2-$langcode", 2); + $this->assertNoOptionSelected("edit-card-2-$locale", 0); + $this->assertNoOptionSelected("edit-card-2-$locale", 1); + $this->assertNoOptionSelected("edit-card-2-$locale", 2); $this->assertRaw('Some dangerous & unescaped markup', t('Option text was properly filtered.')); $this->assertRaw('Group 1', t('Option groups are displayed.')); // Submit form: select first option. - $edit = array("card_2[$langcode][]" => array(0 => 0)); + $edit = array("card_2[$locale][]" => array(0 => 0)); $this->drupalPost(NULL, $edit, t('Save')); - $this->assertFieldValues($entity_init, 'card_2', $langcode, array(0)); + $this->assertFieldValues($entity_init, 'card_2', $locale, array(0)); // Display form: check that the right options are selected. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); - $this->assertOptionSelected("edit-card-2-$langcode", 0); - $this->assertNoOptionSelected("edit-card-2-$langcode", 1); - $this->assertNoOptionSelected("edit-card-2-$langcode", 2); + $this->assertOptionSelected("edit-card-2-$locale", 0); + $this->assertNoOptionSelected("edit-card-2-$locale", 1); + $this->assertNoOptionSelected("edit-card-2-$locale", 2); // Submit form: Unselect the option. - $edit = array("card_2[$langcode][]" => array('_none' => '_none')); + $edit = array("card_2[$locale][]" => array('_none' => '_none')); $this->drupalPost('test-entity/manage/' . $entity->ftid . '/edit', $edit, t('Save')); - $this->assertFieldValues($entity_init, 'card_2', $langcode, array()); + $this->assertFieldValues($entity_init, 'card_2', $locale, array()); } /** @@ -427,7 +427,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { ), ); $instance = field_create_instance($instance); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // Create an entity. $entity_init = field_test_create_stub_entity(); @@ -437,26 +437,26 @@ class OptionsWidgetsTestCase extends FieldTestCase { // Display form: with no field data, option is unchecked. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); - $this->assertNoFieldChecked("edit-bool-$langcode"); + $this->assertNoFieldChecked("edit-bool-$locale"); $this->assertRaw('Some dangerous & unescaped markup', t('Option text was properly filtered.')); // Submit form: check the option. - $edit = array("bool[$langcode]" => TRUE); + $edit = array("bool[$locale]" => TRUE); $this->drupalPost(NULL, $edit, t('Save')); - $this->assertFieldValues($entity_init, 'bool', $langcode, array(0)); + $this->assertFieldValues($entity_init, 'bool', $locale, array(0)); // Display form: check that the right options are selected. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); - $this->assertFieldChecked("edit-bool-$langcode"); + $this->assertFieldChecked("edit-bool-$locale"); // Submit form: uncheck the option. - $edit = array("bool[$langcode]" => FALSE); + $edit = array("bool[$locale]" => FALSE); $this->drupalPost(NULL, $edit, t('Save')); - $this->assertFieldValues($entity_init, 'bool', $langcode, array(1)); + $this->assertFieldValues($entity_init, 'bool', $locale, array(1)); // Display form: with 'off' value, option is unchecked. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); - $this->assertNoFieldChecked("edit-bool-$langcode"); + $this->assertNoFieldChecked("edit-bool-$locale"); // Create admin user. $admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer taxonomy')); diff --git a/modules/field/modules/text/text.module b/modules/field/modules/text/text.module index 89c605c..5f71e59 100644 --- a/modules/field/modules/text/text.module +++ b/modules/field/modules/text/text.module @@ -115,7 +115,7 @@ function text_field_instance_settings_form($field, $instance) { * - 'text_value_max_length': The value exceeds the maximum length. * - 'text_summary_max_length': The summary exceeds the maximum length. */ -function text_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) { +function text_field_validate($entity_type, $entity, $field, $instance, $locale, $items, &$errors) { foreach ($items as $delta => $item) { // @todo Length is counted separately for summary and value, so the maximum // length can be exceeded very easily. @@ -131,7 +131,7 @@ function text_field_validate($entity_type, $entity, $field, $instance, $langcode $message = t('%name: the summary may not be longer than %max characters.', array('%name' => $instance['label'], '%max' => $field['settings']['max_length'])); break; } - $errors[$field['field_name']][$langcode][$delta][] = array( + $errors[$field['field_name']][$locale][$delta][] = array( 'error' => "text_{$column}_length", 'message' => $message, ); @@ -150,15 +150,15 @@ function text_field_validate($entity_type, $entity, $field, $instance, $langcode * * @see text_field_formatter_view() */ -function text_field_load($entity_type, $entities, $field, $instances, $langcode, &$items) { +function text_field_load($entity_type, $entities, $field, $instances, $locale, &$items) { foreach ($entities as $id => $entity) { foreach ($items[$id] as $delta => $item) { // Only process items with a cacheable format, the rest will be handled // by formatters if needed. if (empty($instances[$id]['settings']['text_processing']) || filter_format_allowcache($item['format'])) { - $items[$id][$delta]['safe_value'] = isset($item['value']) ? _text_sanitize($instances[$id], $langcode, $item, 'value') : ''; + $items[$id][$delta]['safe_value'] = isset($item['value']) ? _text_sanitize($instances[$id], $locale, $item, 'value') : ''; if ($field['type'] == 'text_with_summary') { - $items[$id][$delta]['safe_summary'] = isset($item['summary']) ? _text_sanitize($instances[$id], $langcode, $item, 'summary') : ''; + $items[$id][$delta]['safe_summary'] = isset($item['summary']) ? _text_sanitize($instances[$id], $locale, $item, 'summary') : ''; } } } @@ -254,14 +254,14 @@ function text_field_formatter_settings_summary($field, $instance, $view_mode) { /** * Implements hook_field_formatter_view(). */ -function text_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { +function text_field_formatter_view($entity_type, $entity, $field, $instance, $locale, $items, $display) { $element = array(); switch ($display['type']) { case 'text_default': case 'text_trimmed': foreach ($items as $delta => $item) { - $output = _text_sanitize($instance, $langcode, $item, 'value'); + $output = _text_sanitize($instance, $locale, $item, 'value'); if ($display['type'] == 'text_trimmed') { $output = text_summary($output, $instance['settings']['text_processing'] ? $item['format'] : NULL, $display['settings']['trim_length']); } @@ -272,10 +272,10 @@ function text_field_formatter_view($entity_type, $entity, $field, $instance, $la case 'text_summary_or_trimmed': foreach ($items as $delta => $item) { if (!empty($item['summary'])) { - $output = _text_sanitize($instance, $langcode, $item, 'summary'); + $output = _text_sanitize($instance, $locale, $item, 'summary'); } else { - $output = _text_sanitize($instance, $langcode, $item, 'value'); + $output = _text_sanitize($instance, $locale, $item, 'value'); $output = text_summary($output, $instance['settings']['text_processing'] ? $item['format'] : NULL, $display['settings']['trim_length']); } $element[$delta] = array('#markup' => $output); @@ -300,7 +300,7 @@ function text_field_formatter_view($entity_type, $entity, $field, $instance, $la * * @param $instance * The instance definition. - * @param $langcode + * @param $locale * The language associated to $item. * @param $item * The field value to sanitize. @@ -310,13 +310,13 @@ function text_field_formatter_view($entity_type, $entity, $field, $instance, $la * @return * The sanitized string. */ -function _text_sanitize($instance, $langcode, $item, $column) { +function _text_sanitize($instance, $locale, $item, $column) { // If the value uses a cacheable text format, text_field_load() precomputes // the sanitized string. if (isset($item["safe_$column"])) { return $item["safe_$column"]; } - return $instance['settings']['text_processing'] ? check_markup($item[$column], $item['format'], $langcode) : check_plain($item[$column]); + return $instance['settings']['text_processing'] ? check_markup($item[$column], $item['format'], $locale) : check_plain($item[$column]); } /** @@ -499,7 +499,7 @@ function text_field_widget_settings_form($field, $instance) { /** * Implements hook_field_widget_form(). */ -function text_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) { +function text_field_widget_form(&$form, &$form_state, $field, $instance, $locale, $items, $delta, $element) { $summary_widget = array(); $main_widget = array(); @@ -581,13 +581,13 @@ function text_field_widget_error($element, $error, $form, &$form_state) { /** * Implements hook_field_prepare_translation(). */ -function text_field_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode) { +function text_field_prepare_translation($entity_type, $entity, $field, $instance, $locale, &$items, $source_entity, $source_locale) { // If the translating user is not permitted to use the assigned text format, // we must not expose the source values. $field_name = $field['field_name']; - if (!empty($source_entity->{$field_name}[$source_langcode])) { + if (!empty($source_entity->{$field_name}[$source_locale])) { $formats = filter_formats(); - foreach ($source_entity->{$field_name}[$source_langcode] as $delta => $item) { + foreach ($source_entity->{$field_name}[$source_locale] as $delta => $item) { $format_id = $item['format']; if (!empty($format_id) && !filter_access($formats[$format_id])) { unset($items[$delta]); diff --git a/modules/field/modules/text/text.test b/modules/field/modules/text/text.test index b42fed7..5bd1fe4 100644 --- a/modules/field/modules/text/text.test +++ b/modules/field/modules/text/text.test @@ -58,9 +58,9 @@ class TextFieldTestCase extends DrupalWebTestCase { field_create_instance($this->instance); // Test valid and invalid values with field_attach_validate(). $entity = field_test_create_stub_entity(); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; for ($i = 0; $i <= $max_length + 2; $i++) { - $entity->{$this->field['field_name']}[$langcode][0]['value'] = str_repeat('x', $i); + $entity->{$this->field['field_name']}[$locale][0]['value'] = str_repeat('x', $i); try { field_attach_validate('test_entity', $entity); $this->assertTrue($i <= $max_length, "Length $i does not cause validation error when max_length is $max_length"); @@ -106,17 +106,17 @@ class TextFieldTestCase extends DrupalWebTestCase { ), ); field_create_instance($this->instance); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // Display creation form. $this->drupalGet('test-entity/add/test-bundle'); - $this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', t('Widget is displayed')); - $this->assertNoFieldByName("{$this->field_name}[$langcode][0][format]", '1', t('Format selector is not displayed')); + $this->assertFieldByName("{$this->field_name}[$locale][0][value]", '', t('Widget is displayed')); + $this->assertNoFieldByName("{$this->field_name}[$locale][0][format]", '1', t('Format selector is not displayed')); // Submit with some value. $value = $this->randomName(); $edit = array( - "{$this->field_name}[$langcode][0][value]" => $value, + "{$this->field_name}[$locale][0][value]" => $value, ); $this->drupalPost(NULL, $edit, t('Save')); preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match); @@ -165,7 +165,7 @@ class TextFieldTestCase extends DrupalWebTestCase { ), ); field_create_instance($this->instance); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // Disable all text formats besides the plain text fallback format. $this->drupalLogin($this->admin_user); @@ -179,13 +179,13 @@ class TextFieldTestCase extends DrupalWebTestCase { // Display the creation form. Since the user only has access to one format, // no format selector will be displayed. $this->drupalGet('test-entity/add/test-bundle'); - $this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', t('Widget is displayed')); - $this->assertNoFieldByName("{$this->field_name}[$langcode][0][format]", '', t('Format selector is not displayed')); + $this->assertFieldByName("{$this->field_name}[$locale][0][value]", '', t('Widget is displayed')); + $this->assertNoFieldByName("{$this->field_name}[$locale][0][format]", '', t('Format selector is not displayed')); // Submit with data that should be filtered. $value = '' . $this->randomName() . ''; $edit = array( - "{$this->field_name}[$langcode][0][value]" => $value, + "{$this->field_name}[$locale][0][value]" => $value, ); $this->drupalPost(NULL, $edit, t('Save')); preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match); @@ -219,12 +219,12 @@ class TextFieldTestCase extends DrupalWebTestCase { // Display edition form. // We should now have a 'text format' selector. $this->drupalGet('test-entity/manage/' . $id . '/edit'); - $this->assertFieldByName("{$this->field_name}[$langcode][0][value]", NULL, t('Widget is displayed')); - $this->assertFieldByName("{$this->field_name}[$langcode][0][format]", NULL, t('Format selector is displayed')); + $this->assertFieldByName("{$this->field_name}[$locale][0][value]", NULL, t('Widget is displayed')); + $this->assertFieldByName("{$this->field_name}[$locale][0][format]", NULL, t('Format selector is displayed')); // Edit and change the text format to the new one that was created. $edit = array( - "{$this->field_name}[$langcode][0][format]" => $format_id, + "{$this->field_name}[$locale][0][format]" => $format_id, ); $this->drupalPost(NULL, $edit, t('Save')); $this->assertRaw(t('test_entity @id has been updated.', array('@id' => $id)), t('Entity was updated')); @@ -430,7 +430,7 @@ class TextTranslationTestCase extends DrupalWebTestCase { // Enable an additional language. $this->drupalLogin($this->admin); - $edit = array('langcode' => 'fr'); + $edit = array('locale' => 'fr'); $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); // Set "Article" content type to use multilingual support with translation. @@ -451,12 +451,12 @@ class TextTranslationTestCase extends DrupalWebTestCase { $this->drupalLogin($this->translator); // Create content. - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $body = $this->randomName(); $edit = array( "title" => $this->randomName(), "language" => 'en', - "body[$langcode][0][value]" => $body, + "body[$locale][0][value]" => $body, ); // Translate the article in french. @@ -484,11 +484,11 @@ class TextTranslationTestCase extends DrupalWebTestCase { ); // Create an article with the first body input format set to "Full HTML". - $langcode = 'en'; + $locale = 'en'; $title = $this->randomName(); $edit = array( 'title' => $title, - 'language' => $langcode, + 'language' => $locale, ); $this->drupalPost('node/add/article', $edit, t('Save')); @@ -497,8 +497,8 @@ class TextTranslationTestCase extends DrupalWebTestCase { $formats = array('full_html', 'filtered_html'); foreach ($body as $delta => $value) { $edit = array( - "body[$langcode][$delta][value]" => $value, - "body[$langcode][$delta][format]" => array_shift($formats), + "body[$locale][$delta][value]" => $value, + "body[$locale][$delta][format]" => array_shift($formats), ); $this->drupalPost('node/1/edit', $edit, t('Save')); $this->assertText($body[$delta], t('The body field with delta @delta has been saved.', array('@delta' => $delta))); diff --git a/modules/field/tests/field.test b/modules/field/tests/field.test index ebb1c9f..c7d7961 100644 --- a/modules/field/tests/field.test +++ b/modules/field/tests/field.test @@ -53,17 +53,17 @@ class FieldTestCase extends DrupalWebTestCase { * The entity to test. * @param $field_name * The name of the field to test - * @param $langcode + * @param $locale * The language code for the values. * @param $expected_values * The array of expected values. * @param $column * (Optional) the name of the column to check. */ - function assertFieldValues($entity, $field_name, $langcode, $expected_values, $column = 'value') { + function assertFieldValues($entity, $field_name, $locale, $expected_values, $column = 'value') { $e = clone $entity; field_attach_load('test_entity', array($e->ftid => $e)); - $values = isset($e->{$field_name}[$langcode]) ? $e->{$field_name}[$langcode] : array(); + $values = isset($e->{$field_name}[$locale]) ? $e->{$field_name}[$locale] : array(); $this->assertEqual(count($values), count($expected_values), t('Expected number of values were saved.')); foreach ($expected_values as $key => $value) { $this->assertEqual($values[$key][$column], $value, t('Value @value was saved correctly.', array('@value' => $value))); @@ -136,7 +136,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { // field_test_field_load() in field_test.module). $this->instance['settings']['test_hook_field_load'] = TRUE; field_update_instance($this->instance); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $entity_type = 'test_entity'; $values = array(); @@ -151,12 +151,12 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $current_revision = $revision_id; // If this is the first revision do an insert. if (!$revision_id) { - $revision[$revision_id]->{$this->field_name}[$langcode] = $values[$revision_id]; + $revision[$revision_id]->{$this->field_name}[$locale] = $values[$revision_id]; field_attach_insert($entity_type, $revision[$revision_id]); } else { // Otherwise do an update. - $revision[$revision_id]->{$this->field_name}[$langcode] = $values[$revision_id]; + $revision[$revision_id]->{$this->field_name}[$locale] = $values[$revision_id]; field_attach_update($entity_type, $revision[$revision_id]); } } @@ -165,12 +165,12 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = field_test_create_stub_entity(0, 0, $this->instance['bundle']); field_attach_load($entity_type, array(0 => $entity)); // Number of values per field loaded equals the field cardinality. - $this->assertEqual(count($entity->{$this->field_name}[$langcode]), $this->field['cardinality'], t('Current revision: expected number of values')); + $this->assertEqual(count($entity->{$this->field_name}[$locale]), $this->field['cardinality'], t('Current revision: expected number of values')); for ($delta = 0; $delta < $this->field['cardinality']; $delta++) { // The field value loaded matches the one inserted or updated. - $this->assertEqual($entity->{$this->field_name}[$langcode][$delta]['value'] , $values[$current_revision][$delta]['value'], t('Current revision: expected value %delta was found.', array('%delta' => $delta))); + $this->assertEqual($entity->{$this->field_name}[$locale][$delta]['value'] , $values[$current_revision][$delta]['value'], t('Current revision: expected value %delta was found.', array('%delta' => $delta))); // The value added in hook_field_load() is found. - $this->assertEqual($entity->{$this->field_name}[$langcode][$delta]['additional_key'], 'additional_value', t('Current revision: extra information for value %delta was found', array('%delta' => $delta))); + $this->assertEqual($entity->{$this->field_name}[$locale][$delta]['additional_key'], 'additional_value', t('Current revision: extra information for value %delta was found', array('%delta' => $delta))); } // Confirm each revision loads the correct data. @@ -178,12 +178,12 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = field_test_create_stub_entity(0, $revision_id, $this->instance['bundle']); field_attach_load_revision($entity_type, array(0 => $entity)); // Number of values per field loaded equals the field cardinality. - $this->assertEqual(count($entity->{$this->field_name}[$langcode]), $this->field['cardinality'], t('Revision %revision_id: expected number of values.', array('%revision_id' => $revision_id))); + $this->assertEqual(count($entity->{$this->field_name}[$locale]), $this->field['cardinality'], t('Revision %revision_id: expected number of values.', array('%revision_id' => $revision_id))); for ($delta = 0; $delta < $this->field['cardinality']; $delta++) { // The field value loaded matches the one inserted or updated. - $this->assertEqual($entity->{$this->field_name}[$langcode][$delta]['value'], $values[$revision_id][$delta]['value'], t('Revision %revision_id: expected value %delta was found.', array('%revision_id' => $revision_id, '%delta' => $delta))); + $this->assertEqual($entity->{$this->field_name}[$locale][$delta]['value'], $values[$revision_id][$delta]['value'], t('Revision %revision_id: expected value %delta was found.', array('%revision_id' => $revision_id, '%delta' => $delta))); // The value added in hook_field_load() is found. - $this->assertEqual($entity->{$this->field_name}[$langcode][$delta]['additional_key'], 'additional_value', t('Revision %revision_id: extra information for value %delta was found', array('%revision_id' => $revision_id, '%delta' => $delta))); + $this->assertEqual($entity->{$this->field_name}[$locale][$delta]['additional_key'], 'additional_value', t('Revision %revision_id: extra information for value %delta was found', array('%revision_id' => $revision_id, '%delta' => $delta))); } } } @@ -193,7 +193,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { */ function testFieldAttachLoadMultiple() { $entity_type = 'test_entity'; - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // Define 2 bundles. $bundles = array( @@ -238,7 +238,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $instances = field_info_instances('test_entity', $bundle); foreach ($instances as $field_name => $instance) { $values[$index][$field_name] = mt_rand(1, 127); - $entity->$field_name = array($langcode => array(array('value' => $values[$index][$field_name]))); + $entity->$field_name = array($locale => array(array('value' => $values[$index][$field_name]))); } field_attach_insert($entity_type, $entity); } @@ -249,17 +249,17 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $instances = field_info_instances($entity_type, $bundles[$index]); foreach ($instances as $field_name => $instance) { // The field value loaded matches the one inserted. - $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], $values[$index][$field_name], t('Entity %index: expected value was found.', array('%index' => $index))); + $this->assertEqual($entity->{$field_name}[$locale][0]['value'], $values[$index][$field_name], t('Entity %index: expected value was found.', array('%index' => $index))); // The value added in hook_field_load() is found. - $this->assertEqual($entity->{$field_name}[$langcode][0]['additional_key'], 'additional_value', t('Entity %index: extra information was found', array('%index' => $index))); + $this->assertEqual($entity->{$field_name}[$locale][0]['additional_key'], 'additional_value', t('Entity %index: extra information was found', array('%index' => $index))); } } // Check that the single-field load option works. $entity = field_test_create_stub_entity(1, 1, $bundles[1]); field_attach_load($entity_type, array(1 => $entity), FIELD_LOAD_CURRENT, array('field_id' => $field_ids[1])); - $this->assertEqual($entity->{$field_names[1]}[$langcode][0]['value'], $values[1][$field_names[1]], t('Entity %index: expected value was found.', array('%index' => 1))); - $this->assertEqual($entity->{$field_names[1]}[$langcode][0]['additional_key'], 'additional_value', t('Entity %index: extra information was found', array('%index' => 1))); + $this->assertEqual($entity->{$field_names[1]}[$locale][0]['value'], $values[1][$field_names[1]], t('Entity %index: expected value was found.', array('%index' => 1))); + $this->assertEqual($entity->{$field_names[1]}[$locale][0]['additional_key'], 'additional_value', t('Entity %index: extra information was found', array('%index' => 1))); $this->assert(!isset($entity->{$field_names[2]}), t('Entity %index: field %field_name is not loaded.', array('%index' => 2, '%field_name' => $field_names[2]))); $this->assert(!isset($entity->{$field_names[3]}), t('Entity %index: field %field_name is not loaded.', array('%index' => 3, '%field_name' => $field_names[3]))); } @@ -269,7 +269,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { */ function testFieldAttachSaveLoadDifferentStorage() { $entity_type = 'test_entity'; - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // Create two fields using different storage backends, and their instances. $fields = array( @@ -303,7 +303,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $values = array(); foreach ($fields as $field) { $values[$field['field_name']] = $this->_generateTestFieldValues($this->field['cardinality']); - $entity->{$field['field_name']}[$langcode] = $values[$field['field_name']]; + $entity->{$field['field_name']}[$locale] = $values[$field['field_name']]; } field_attach_insert($entity_type, $entity); @@ -311,7 +311,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); foreach ($fields as $field) { - $this->assertEqual($values[$field['field_name']], $entity->{$field['field_name']}[$langcode], t('%storage storage: expected values were found.', array('%storage' => $field['storage']['type']))); + $this->assertEqual($values[$field['field_name']], $entity->{$field['field_name']}[$locale], t('%storage storage: expected values were found.', array('%storage' => $field['storage']['type']))); } } @@ -363,7 +363,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { function testFieldAttachSaveMissingData() { $entity_type = 'test_entity'; $entity_init = field_test_create_stub_entity(); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // Insert: Field is missing. $entity = clone($entity_init); @@ -387,12 +387,12 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { field_cache_clear(); $entity = clone($entity_init); $values = $this->_generateTestFieldValues(1); - $entity->{$this->field_name}[$langcode] = $values; + $entity->{$this->field_name}[$locale] = $values; field_attach_insert($entity_type, $entity); $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertEqual($entity->{$this->field_name}[$langcode], $values, t('Field data saved')); + $this->assertEqual($entity->{$this->field_name}[$locale], $values, t('Field data saved')); // Update: Field is missing. Data should survive. field_cache_clear(); @@ -401,7 +401,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertEqual($entity->{$this->field_name}[$langcode], $values, t('Update: missing field leaves existing values in place')); + $this->assertEqual($entity->{$this->field_name}[$locale], $values, t('Update: missing field leaves existing values in place')); // Update: Field is NULL. Data should be wiped. field_cache_clear(); @@ -417,12 +417,12 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { field_cache_clear(); $entity = clone($entity_init); $values = $this->_generateTestFieldValues(1); - $entity->{$this->field_name}[$langcode] = $values; + $entity->{$this->field_name}[$locale] = $values; field_attach_update($entity_type, $entity); $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertEqual($entity->{$this->field_name}[$langcode], $values, t('Field data saved')); + $this->assertEqual($entity->{$this->field_name}[$locale], $values, t('Field data saved')); // Update: Field is empty array. Data should be wiped. field_cache_clear(); @@ -445,16 +445,16 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity_type = 'test_entity'; $entity_init = field_test_create_stub_entity(); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // Insert: Field is NULL. $entity = clone($entity_init); - $entity->{$this->field_name}[$langcode] = NULL; + $entity->{$this->field_name}[$locale] = NULL; field_attach_insert($entity_type, $entity); $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertTrue(empty($entity->{$this->field_name}[$langcode]), t('Insert: NULL field results in no value saved')); + $this->assertTrue(empty($entity->{$this->field_name}[$locale]), t('Insert: NULL field results in no value saved')); // Insert: Field is missing. field_cache_clear(); @@ -464,7 +464,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); $values = field_test_default_value($entity_type, $entity, $this->field, $this->instance); - $this->assertEqual($entity->{$this->field_name}[$langcode], $values, t('Insert: missing field results in default value saved')); + $this->assertEqual($entity->{$this->field_name}[$locale], $values, t('Insert: missing field results in default value saved')); } /** @@ -472,29 +472,29 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { */ function testFieldAttachDelete() { $entity_type = 'test_entity'; - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $rev[0] = field_test_create_stub_entity(0, 0, $this->instance['bundle']); // Create revision 0 $values = $this->_generateTestFieldValues($this->field['cardinality']); - $rev[0]->{$this->field_name}[$langcode] = $values; + $rev[0]->{$this->field_name}[$locale] = $values; field_attach_insert($entity_type, $rev[0]); // Create revision 1 $rev[1] = field_test_create_stub_entity(0, 1, $this->instance['bundle']); - $rev[1]->{$this->field_name}[$langcode] = $values; + $rev[1]->{$this->field_name}[$locale] = $values; field_attach_update($entity_type, $rev[1]); // Create revision 2 $rev[2] = field_test_create_stub_entity(0, 2, $this->instance['bundle']); - $rev[2]->{$this->field_name}[$langcode] = $values; + $rev[2]->{$this->field_name}[$locale] = $values; field_attach_update($entity_type, $rev[2]); // Confirm each revision loads foreach (array_keys($rev) as $vid) { $read = field_test_create_stub_entity(0, $vid, $this->instance['bundle']); field_attach_load_revision($entity_type, array(0 => $read)); - $this->assertEqual(count($read->{$this->field_name}[$langcode]), $this->field['cardinality'], "The test entity revision $vid has {$this->field['cardinality']} values."); + $this->assertEqual(count($read->{$this->field_name}[$locale]), $this->field['cardinality'], "The test entity revision $vid has {$this->field['cardinality']} values."); } // Delete revision 1, confirm the other two still load. @@ -502,13 +502,13 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { foreach (array(0, 2) as $vid) { $read = field_test_create_stub_entity(0, $vid, $this->instance['bundle']); field_attach_load_revision($entity_type, array(0 => $read)); - $this->assertEqual(count($read->{$this->field_name}[$langcode]), $this->field['cardinality'], "The test entity revision $vid has {$this->field['cardinality']} values."); + $this->assertEqual(count($read->{$this->field_name}[$locale]), $this->field['cardinality'], "The test entity revision $vid has {$this->field['cardinality']} values."); } // Confirm the current revision still loads $read = field_test_create_stub_entity(0, 2, $this->instance['bundle']); field_attach_load($entity_type, array(0 => $read)); - $this->assertEqual(count($read->{$this->field_name}[$langcode]), $this->field['cardinality'], "The test entity current revision has {$this->field['cardinality']} values."); + $this->assertEqual(count($read->{$this->field_name}[$locale]), $this->field['cardinality'], "The test entity current revision has {$this->field['cardinality']} values."); // Delete all field data, confirm nothing loads field_attach_delete($entity_type, $rev[2]); @@ -537,16 +537,16 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { // Save an entity with data in the field. $entity = field_test_create_stub_entity(0, 0, $this->instance['bundle']); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $values = $this->_generateTestFieldValues($this->field['cardinality']); - $entity->{$this->field_name}[$langcode] = $values; + $entity->{$this->field_name}[$locale] = $values; $entity_type = 'test_entity'; field_attach_insert($entity_type, $entity); // Verify the field data is present on load. $entity = field_test_create_stub_entity(0, 0, $this->instance['bundle']); field_attach_load($entity_type, array(0 => $entity)); - $this->assertEqual(count($entity->{$this->field_name}[$langcode]), $this->field['cardinality'], "Data is retrieved for the new bundle"); + $this->assertEqual(count($entity->{$this->field_name}[$locale]), $this->field['cardinality'], "Data is retrieved for the new bundle"); // Rename the bundle. This has to be initiated by the module so that its // hook_entity_info() is consistent. @@ -560,7 +560,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { // Verify the field data is present on load. $entity = field_test_create_stub_entity(0, 0, $new_bundle); field_attach_load($entity_type, array(0 => $entity)); - $this->assertEqual(count($entity->{$this->field_name}[$langcode]), $this->field['cardinality'], "Bundle name has been updated in the field storage"); + $this->assertEqual(count($entity->{$this->field_name}[$locale]), $this->field['cardinality'], "Bundle name has been updated in the field storage"); } /** @@ -596,17 +596,17 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { // Save an entity with data for both fields $entity = field_test_create_stub_entity(0, 0, $this->instance['bundle']); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $values = $this->_generateTestFieldValues($this->field['cardinality']); - $entity->{$this->field_name}[$langcode] = $values; - $entity->{$field_name}[$langcode] = $this->_generateTestFieldValues(1); + $entity->{$this->field_name}[$locale] = $values; + $entity->{$field_name}[$locale] = $this->_generateTestFieldValues(1); field_attach_insert('test_entity', $entity); // Verify the fields are present on load $entity = field_test_create_stub_entity(0, 0, $this->instance['bundle']); field_attach_load('test_entity', array(0 => $entity)); - $this->assertEqual(count($entity->{$this->field_name}[$langcode]), 4, 'First field got loaded'); - $this->assertEqual(count($entity->{$field_name}[$langcode]), 1, 'Second field got loaded'); + $this->assertEqual(count($entity->{$this->field_name}[$locale]), 4, 'First field got loaded'); + $this->assertEqual(count($entity->{$field_name}[$locale]), 1, 'Second field got loaded'); // Delete the bundle. This has to be initiated by the module so that its // hook_entity_info() is consistent. @@ -615,8 +615,8 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { // Verify no data gets loaded $entity = field_test_create_stub_entity(0, 0, $this->instance['bundle']); field_attach_load('test_entity', array(0 => $entity)); - $this->assertFalse(isset($entity->{$this->field_name}[$langcode]), 'No data for first field'); - $this->assertFalse(isset($entity->{$field_name}[$langcode]), 'No data for second field'); + $this->assertFalse(isset($entity->{$this->field_name}[$locale]), 'No data for first field'); + $this->assertFalse(isset($entity->{$field_name}[$locale]), 'No data for second field'); // Verify that the instances are gone $this->assertFalse(field_read_instance('test_entity', $this->field_name, $this->instance['bundle']), "First field is deleted"); @@ -642,11 +642,11 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { function testFieldAttachView() { $entity_type = 'test_entity'; $entity_init = field_test_create_stub_entity(); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // Populate values to be displayed. $values = $this->_generateTestFieldValues($this->field['cardinality']); - $entity_init->{$this->field_name}[$langcode] = $values; + $entity_init->{$this->field_name}[$locale] = $values; // Simple formatter, label displayed. $entity = clone($entity_init); @@ -766,7 +766,7 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { */ function testFieldAttachPrepareViewMultiple() { $entity_type = 'test_entity'; - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // Set the instance to be hidden. $this->instance['display']['full']['type'] = 'hidden'; @@ -789,25 +789,25 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { // Create one entity in each bundle. $entity1_init = field_test_create_stub_entity(1, 1, 'test_bundle'); $values1 = $this->_generateTestFieldValues($this->field['cardinality']); - $entity1_init->{$this->field_name}[$langcode] = $values1; + $entity1_init->{$this->field_name}[$locale] = $values1; $entity2_init = field_test_create_stub_entity(2, 2, 'test_bundle_2'); $values2 = $this->_generateTestFieldValues($this->field['cardinality']); - $entity2_init->{$this->field_name}[$langcode] = $values2; + $entity2_init->{$this->field_name}[$locale] = $values2; // Run prepare_view, and check that the entities come out as expected. $entity1 = clone($entity1_init); $entity2 = clone($entity2_init); field_attach_prepare_view($entity_type, array($entity1->ftid => $entity1, $entity2->ftid => $entity2), 'full'); - $this->assertFalse(isset($entity1->{$this->field_name}[$langcode][0]['additional_formatter_value']), 'Entity 1 did not run through the prepare_view hook.'); - $this->assertTrue(isset($entity2->{$this->field_name}[$langcode][0]['additional_formatter_value']), 'Entity 2 ran through the prepare_view hook.'); + $this->assertFalse(isset($entity1->{$this->field_name}[$locale][0]['additional_formatter_value']), 'Entity 1 did not run through the prepare_view hook.'); + $this->assertTrue(isset($entity2->{$this->field_name}[$locale][0]['additional_formatter_value']), 'Entity 2 ran through the prepare_view hook.'); // Same thing, reversed order. $entity1 = clone($entity1_init); $entity2 = clone($entity2_init); field_attach_prepare_view($entity_type, array($entity2->ftid => $entity2, $entity1->ftid => $entity1), 'full'); - $this->assertFalse(isset($entity1->{$this->field_name}[$langcode][0]['additional_formatter_value']), 'Entity 1 did not run through the prepare_view hook.'); - $this->assertTrue(isset($entity2->{$this->field_name}[$langcode][0]['additional_formatter_value']), 'Entity 2 ran through the prepare_view hook.'); + $this->assertFalse(isset($entity1->{$this->field_name}[$locale][0]['additional_formatter_value']), 'Entity 1 did not run through the prepare_view hook.'); + $this->assertTrue(isset($entity2->{$this->field_name}[$locale][0]['additional_formatter_value']), 'Entity 2 ran through the prepare_view hook.'); } /** @@ -816,7 +816,7 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { function testFieldAttachCache() { // Initialize random values and a test entity. $entity_init = field_test_create_stub_entity(1, 1, $this->instance['bundle']); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $values = $this->_generateTestFieldValues($this->field['cardinality']); // Non-cacheable entity type. @@ -828,7 +828,7 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { // Save, and check that no cache entry is present. $entity = clone($entity_init); - $entity->{$this->field_name}[$langcode] = $values; + $entity->{$this->field_name}[$locale] = $values; field_attach_insert($entity_type, $entity); $this->assertFalse(cache_get($cid, 'cache_field'), t('Non-cached: no cache entry on insert')); @@ -850,7 +850,7 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { // Save, and check that no cache entry is present. $entity = clone($entity_init); - $entity->{$this->field_name}[$langcode] = $values; + $entity->{$this->field_name}[$locale] = $values; field_attach_insert($entity_type, $entity); $this->assertFalse(cache_get($cid, 'cache_field'), t('Cached: no cache entry on insert')); @@ -864,12 +864,12 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); $cache = cache_get($cid, 'cache_field'); - $this->assertEqual($cache->data[$this->field_name][$langcode], $values, t('Cached: correct cache entry on load')); + $this->assertEqual($cache->data[$this->field_name][$locale], $values, t('Cached: correct cache entry on load')); // Update with different values, and check that the cache entry is wiped. $values = $this->_generateTestFieldValues($this->field['cardinality']); $entity = clone($entity_init); - $entity->{$this->field_name}[$langcode] = $values; + $entity->{$this->field_name}[$locale] = $values; field_attach_update($entity_type, $entity); $this->assertFalse(cache_get($cid, 'cache_field'), t('Cached: no cache entry on update')); @@ -877,13 +877,13 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); $cache = cache_get($cid, 'cache_field'); - $this->assertEqual($cache->data[$this->field_name][$langcode], $values, t('Cached: correct cache entry on load')); + $this->assertEqual($cache->data[$this->field_name][$locale], $values, t('Cached: correct cache entry on load')); // Create a new revision, and check that the cache entry is wiped. $entity_init = field_test_create_stub_entity(1, 2, $this->instance['bundle']); $values = $this->_generateTestFieldValues($this->field['cardinality']); $entity = clone($entity_init); - $entity->{$this->field_name}[$langcode] = $values; + $entity->{$this->field_name}[$locale] = $values; field_attach_update($entity_type, $entity); $cache = cache_get($cid, 'cache_field'); $this->assertFalse(cache_get($cid, 'cache_field'), t('Cached: no cache entry on new revision creation')); @@ -892,7 +892,7 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); $cache = cache_get($cid, 'cache_field'); - $this->assertEqual($cache->data[$this->field_name][$langcode], $values, t('Cached: correct cache entry on load')); + $this->assertEqual($cache->data[$this->field_name][$locale], $values, t('Cached: correct cache entry on load')); // Delete, and check that the cache entry is wiped. field_attach_delete($entity_type, $entity); @@ -908,7 +908,7 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { function testFieldAttachValidate() { $entity_type = 'test_entity'; $entity = field_test_create_stub_entity(0, 0, $this->instance['bundle']); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // Set up values to generate errors $values = array(); @@ -917,7 +917,7 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { } // Arrange for item 1 not to generate an error $values[1]['value'] = 1; - $entity->{$this->field_name}[$langcode] = $values; + $entity->{$this->field_name}[$locale] = $values; try { field_attach_validate($entity_type, $entity); @@ -928,25 +928,25 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { foreach ($values as $delta => $value) { if ($value['value'] != 1) { - $this->assertIdentical($errors[$this->field_name][$langcode][$delta][0]['error'], 'field_test_invalid', "Error set on value $delta"); - $this->assertEqual(count($errors[$this->field_name][$langcode][$delta]), 1, "Only one error set on value $delta"); - unset($errors[$this->field_name][$langcode][$delta]); + $this->assertIdentical($errors[$this->field_name][$locale][$delta][0]['error'], 'field_test_invalid', "Error set on value $delta"); + $this->assertEqual(count($errors[$this->field_name][$locale][$delta]), 1, "Only one error set on value $delta"); + unset($errors[$this->field_name][$locale][$delta]); } else { - $this->assertFalse(isset($errors[$this->field_name][$langcode][$delta]), "No error set on value $delta"); + $this->assertFalse(isset($errors[$this->field_name][$locale][$delta]), "No error set on value $delta"); } } - $this->assertEqual(count($errors[$this->field_name][$langcode]), 0, 'No extraneous errors set'); + $this->assertEqual(count($errors[$this->field_name][$locale]), 0, 'No extraneous errors set'); // Check that cardinality is validated. - $entity->{$this->field_name}[$langcode] = $this->_generateTestFieldValues($this->field['cardinality'] + 1); + $entity->{$this->field_name}[$locale] = $this->_generateTestFieldValues($this->field['cardinality'] + 1); try { field_attach_validate($entity_type, $entity); } catch (FieldValidationException $e) { $errors = $e->errors; } - $this->assertEqual($errors[$this->field_name][$langcode][0][0]['error'], 'field_cardinality', t('Cardinality validation failed.')); + $this->assertEqual($errors[$this->field_name][$locale][0][0]['error'], 'field_cardinality', t('Cardinality validation failed.')); } @@ -964,11 +964,11 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { $form_state = form_state_defaults(); field_attach_form($entity_type, $entity, $form, $form_state); - $langcode = LANGUAGE_NONE; - $this->assertEqual($form[$this->field_name][$langcode]['#title'], $this->instance['label'], "Form title is {$this->instance['label']}"); + $locale = LANGUAGE_NONE; + $this->assertEqual($form[$this->field_name][$locale]['#title'], $this->instance['label'], "Form title is {$this->instance['label']}"); for ($delta = 0; $delta < $this->field['cardinality']; $delta++) { // field_test_widget uses 'textfield' - $this->assertEqual($form[$this->field_name][$langcode][$delta]['value']['#type'], 'textfield', "Form delta $delta widget is textfield"); + $this->assertEqual($form[$this->field_name][$locale][$delta]['value']['#type'], 'textfield', "Form delta $delta widget is textfield"); } } @@ -999,11 +999,11 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { // Leave an empty value. 'field_test' fields are empty if empty(). $values[1]['value'] = 0; - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // Pretend the form has been built. drupal_prepare_form('field_test_entity_form', $form, $form_state); drupal_process_form('field_test_entity_form', $form, $form_state); - $form_state['values'][$this->field_name][$langcode] = $values; + $form_state['values'][$this->field_name][$locale] = $values; field_attach_submit($entity_type, $entity, $form, $form_state); asort($weights); @@ -1013,7 +1013,7 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { $expected_values[] = array('value' => $values[$key]['value']); } } - $this->assertIdentical($entity->{$this->field_name}[$langcode], $expected_values, 'Submit filters empty values'); + $this->assertIdentical($entity->{$this->field_name}[$locale], $expected_values, 'Submit filters empty values'); } } @@ -1297,46 +1297,46 @@ class FieldFormTestCase extends FieldTestCase { $this->instance['field_name'] = $this->field_name; field_create_field($this->field); field_create_instance($this->instance); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // Display creation form. $this->drupalGet('test-entity/add/test-bundle'); - $this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', 'Widget is displayed'); - $this->assertNoField("{$this->field_name}[$langcode][1][value]", 'No extraneous widget is displayed'); + $this->assertFieldByName("{$this->field_name}[$locale][0][value]", '', 'Widget is displayed'); + $this->assertNoField("{$this->field_name}[$locale][1][value]", 'No extraneous widget is displayed'); // TODO : check that the widget is populated with default value ? // Submit with invalid value (field-level validation). - $edit = array("{$this->field_name}[$langcode][0][value]" => -1); + $edit = array("{$this->field_name}[$locale][0][value]" => -1); $this->drupalPost(NULL, $edit, t('Save')); $this->assertRaw(t('%name does not accept the value -1.', array('%name' => $this->instance['label'])), 'Field validation fails with invalid input.'); // TODO : check that the correct field is flagged for error. // Create an entity $value = mt_rand(1, 127); - $edit = array("{$this->field_name}[$langcode][0][value]" => $value); + $edit = array("{$this->field_name}[$locale][0][value]" => $value); $this->drupalPost(NULL, $edit, t('Save')); preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match); $id = $match[1]; $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), 'Entity was created'); $entity = field_test_entity_test_load($id); - $this->assertEqual($entity->{$this->field_name}[$langcode][0]['value'], $value, 'Field value was saved'); + $this->assertEqual($entity->{$this->field_name}[$locale][0]['value'], $value, 'Field value was saved'); // Display edit form. $this->drupalGet('test-entity/manage/' . $id . '/edit'); - $this->assertFieldByName("{$this->field_name}[$langcode][0][value]", $value, 'Widget is displayed with the correct default value'); - $this->assertNoField("{$this->field_name}[$langcode][1][value]", 'No extraneous widget is displayed'); + $this->assertFieldByName("{$this->field_name}[$locale][0][value]", $value, 'Widget is displayed with the correct default value'); + $this->assertNoField("{$this->field_name}[$locale][1][value]", 'No extraneous widget is displayed'); // Update the entity. $value = mt_rand(1, 127); - $edit = array("{$this->field_name}[$langcode][0][value]" => $value); + $edit = array("{$this->field_name}[$locale][0][value]" => $value); $this->drupalPost(NULL, $edit, t('Save')); $this->assertRaw(t('test_entity @id has been updated.', array('@id' => $id)), 'Entity was updated'); $entity = field_test_entity_test_load($id); - $this->assertEqual($entity->{$this->field_name}[$langcode][0]['value'], $value, 'Field value was updated'); + $this->assertEqual($entity->{$this->field_name}[$locale][0]['value'], $value, 'Field value was updated'); // Empty the field. $value = ''; - $edit = array("{$this->field_name}[$langcode][0][value]" => $value); + $edit = array("{$this->field_name}[$locale][0][value]" => $value); $this->drupalPost('test-entity/manage/' . $id . '/edit', $edit, t('Save')); $this->assertRaw(t('test_entity @id has been updated.', array('@id' => $id)), 'Entity was updated'); $entity = field_test_entity_test_load($id); @@ -1351,7 +1351,7 @@ class FieldFormTestCase extends FieldTestCase { $this->instance['required'] = TRUE; field_create_field($this->field); field_create_instance($this->instance); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // Submit with missing required value. $edit = array(); @@ -1360,17 +1360,17 @@ class FieldFormTestCase extends FieldTestCase { // Create an entity $value = mt_rand(1, 127); - $edit = array("{$this->field_name}[$langcode][0][value]" => $value); + $edit = array("{$this->field_name}[$locale][0][value]" => $value); $this->drupalPost(NULL, $edit, t('Save')); preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match); $id = $match[1]; $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), 'Entity was created'); $entity = field_test_entity_test_load($id); - $this->assertEqual($entity->{$this->field_name}[$langcode][0]['value'], $value, 'Field value was saved'); + $this->assertEqual($entity->{$this->field_name}[$locale][0]['value'], $value, 'Field value was saved'); // Edit with missing required value. $value = ''; - $edit = array("{$this->field_name}[$langcode][0][value]" => $value); + $edit = array("{$this->field_name}[$locale][0][value]" => $value); $this->drupalPost('test-entity/manage/' . $id . '/edit', $edit, t('Save')); $this->assertRaw(t('!name field is required.', array('!name' => $this->instance['label'])), 'Required field with no value fails validation'); } @@ -1389,18 +1389,18 @@ class FieldFormTestCase extends FieldTestCase { $this->instance['field_name'] = $this->field_name; field_create_field($this->field); field_create_instance($this->instance); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // Display creation form -> 1 widget. $this->drupalGet('test-entity/add/test-bundle'); - $this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', 'Widget 1 is displayed'); - $this->assertNoField("{$this->field_name}[$langcode][1][value]", 'No extraneous widget is displayed'); + $this->assertFieldByName("{$this->field_name}[$locale][0][value]", '', 'Widget 1 is displayed'); + $this->assertNoField("{$this->field_name}[$locale][1][value]", 'No extraneous widget is displayed'); // Press 'add more' button -> 2 widgets. $this->drupalPost(NULL, array(), t('Add another item')); - $this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', 'Widget 1 is displayed'); - $this->assertFieldByName("{$this->field_name}[$langcode][1][value]", '', 'New widget is displayed'); - $this->assertNoField("{$this->field_name}[$langcode][2][value]", 'No extraneous widget is displayed'); + $this->assertFieldByName("{$this->field_name}[$locale][0][value]", '', 'Widget 1 is displayed'); + $this->assertFieldByName("{$this->field_name}[$locale][1][value]", '', 'New widget is displayed'); + $this->assertNoField("{$this->field_name}[$locale][2][value]", 'No extraneous widget is displayed'); // TODO : check that non-field inpurs are preserved ('title')... // Yet another time so that we can play with more values -> 3 widgets. @@ -1418,8 +1418,8 @@ class FieldFormTestCase extends FieldTestCase { do { $weight = mt_rand(-$delta_range, $delta_range); } while (in_array($weight, $weights)); - $edit["$this->field_name[$langcode][$delta][value]"] = $value; - $edit["$this->field_name[$langcode][$delta][_weight]"] = $weight; + $edit["$this->field_name[$locale][$delta][value]"] = $value; + $edit["$this->field_name[$locale][$delta][_weight]"] = $weight; // We'll need three slightly different formats to check the values. $values[$delta] = $value; $weights[$delta] = $weight; @@ -1430,15 +1430,15 @@ class FieldFormTestCase extends FieldTestCase { // Press 'add more' button -> 4 widgets $this->drupalPost(NULL, $edit, t('Add another item')); for ($delta = 0; $delta <= $delta_range; $delta++) { - $this->assertFieldByName("$this->field_name[$langcode][$delta][value]", $values[$delta], "Widget $delta is displayed and has the right value"); - $this->assertFieldByName("$this->field_name[$langcode][$delta][_weight]", $weights[$delta], "Widget $delta has the right weight"); + $this->assertFieldByName("$this->field_name[$locale][$delta][value]", $values[$delta], "Widget $delta is displayed and has the right value"); + $this->assertFieldByName("$this->field_name[$locale][$delta][_weight]", $weights[$delta], "Widget $delta has the right weight"); } ksort($pattern); $pattern = implode('.*', array_values($pattern)); $this->assertPattern("|$pattern|s", 'Widgets are displayed in the correct order'); - $this->assertFieldByName("$this->field_name[$langcode][$delta][value]", '', "New widget is displayed"); - $this->assertFieldByName("$this->field_name[$langcode][$delta][_weight]", $delta, "New widget has the right weight"); - $this->assertNoField("$this->field_name[$langcode][" . ($delta + 1) . '][value]', 'No extraneous widget is displayed'); + $this->assertFieldByName("$this->field_name[$locale][$delta][value]", '', "New widget is displayed"); + $this->assertFieldByName("$this->field_name[$locale][$delta][_weight]", $delta, "New widget has the right weight"); + $this->assertNoField("$this->field_name[$locale][" . ($delta + 1) . '][value]', 'No extraneous widget is displayed'); // Submit the form and create the entity. $this->drupalPost(NULL, $edit, t('Save')); @@ -1448,7 +1448,7 @@ class FieldFormTestCase extends FieldTestCase { $entity = field_test_entity_test_load($id); ksort($field_values); $field_values = array_values($field_values); - $this->assertIdentical($entity->{$this->field_name}[$langcode], $field_values, 'Field values were saved in the correct order'); + $this->assertIdentical($entity->{$this->field_name}[$locale], $field_values, 'Field values were saved in the correct order'); // Display edit form: check that the expected number of widgets is // displayed, with correct values change values, reorder, leave an empty @@ -1465,7 +1465,7 @@ class FieldFormTestCase extends FieldTestCase { $this->instance['field_name'] = $this->field_name; field_create_field($this->field); field_create_instance($this->instance); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // Display creation form -> 1 widget. $this->drupalGet('test-entity/add/test-bundle'); @@ -1488,8 +1488,8 @@ class FieldFormTestCase extends FieldTestCase { do { $weight = mt_rand(-$delta_range, $delta_range); } while (in_array($weight, $weights)); - $edit["$this->field_name[$langcode][$delta][value]"] = $value; - $edit["$this->field_name[$langcode][$delta][_weight]"] = $weight; + $edit["$this->field_name[$locale][$delta][value]"] = $value; + $edit["$this->field_name[$locale][$delta][_weight]"] = $weight; // We'll need three slightly different formats to check the values. $values[$delta] = $value; $weights[$delta] = $weight; @@ -1502,15 +1502,15 @@ class FieldFormTestCase extends FieldTestCase { $this->content = $commands[1]['data']; for ($delta = 0; $delta <= $delta_range; $delta++) { - $this->assertFieldByName("$this->field_name[$langcode][$delta][value]", $values[$delta], "Widget $delta is displayed and has the right value"); - $this->assertFieldByName("$this->field_name[$langcode][$delta][_weight]", $weights[$delta], "Widget $delta has the right weight"); + $this->assertFieldByName("$this->field_name[$locale][$delta][value]", $values[$delta], "Widget $delta is displayed and has the right value"); + $this->assertFieldByName("$this->field_name[$locale][$delta][_weight]", $weights[$delta], "Widget $delta has the right weight"); } ksort($pattern); $pattern = implode('.*', array_values($pattern)); $this->assertPattern("|$pattern|s", 'Widgets are displayed in the correct order'); - $this->assertFieldByName("$this->field_name[$langcode][$delta][value]", '', "New widget is displayed"); - $this->assertFieldByName("$this->field_name[$langcode][$delta][_weight]", $delta, "New widget has the right weight"); - $this->assertNoField("$this->field_name[$langcode][" . ($delta + 1) . '][value]', 'No extraneous widget is displayed'); + $this->assertFieldByName("$this->field_name[$locale][$delta][value]", '', "New widget is displayed"); + $this->assertFieldByName("$this->field_name[$locale][$delta][_weight]", $delta, "New widget has the right weight"); + $this->assertNoField("$this->field_name[$locale][" . ($delta + 1) . '][value]', 'No extraneous widget is displayed'); } /** @@ -1525,32 +1525,32 @@ class FieldFormTestCase extends FieldTestCase { $this->instance['widget']['type'] = 'test_field_widget_multiple'; field_create_field($this->field); field_create_instance($this->instance); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // Display creation form. $this->drupalGet('test-entity/add/test-bundle'); - $this->assertFieldByName("{$this->field_name}[$langcode]", '', t('Widget is displayed.')); + $this->assertFieldByName("{$this->field_name}[$locale]", '', t('Widget is displayed.')); // Create entity with three values. - $edit = array("{$this->field_name}[$langcode]" => '1, 2, 3'); + $edit = array("{$this->field_name}[$locale]" => '1, 2, 3'); $this->drupalPost(NULL, $edit, t('Save')); preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match); $id = $match[1]; // Check that the values were saved. $entity_init = field_test_create_stub_entity($id); - $this->assertFieldValues($entity_init, $this->field_name, $langcode, array(1, 2, 3)); + $this->assertFieldValues($entity_init, $this->field_name, $locale, array(1, 2, 3)); // Display the form, check that the values are correctly filled in. $this->drupalGet('test-entity/manage/' . $id . '/edit'); - $this->assertFieldByName("{$this->field_name}[$langcode]", '1, 2, 3', t('Widget is displayed.')); + $this->assertFieldByName("{$this->field_name}[$locale]", '1, 2, 3', t('Widget is displayed.')); // Submit the form with more values than the field accepts. - $edit = array("{$this->field_name}[$langcode]" => '1, 2, 3, 4, 5'); + $edit = array("{$this->field_name}[$locale]" => '1, 2, 3, 4, 5'); $this->drupalPost(NULL, $edit, t('Save')); $this->assertRaw('this field cannot hold more than 4 values', t('Form validation failed.')); // Check that the field values were not submitted. - $this->assertFieldValues($entity_init, $this->field_name, $langcode, array(1, 2, 3)); + $this->assertFieldValues($entity_init, $this->field_name, $locale, array(1, 2, 3)); } /** @@ -1580,36 +1580,36 @@ class FieldFormTestCase extends FieldTestCase { field_create_field($field_no_access); field_create_instance($instance_no_access); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // Display creation form. $this->drupalGet('test-entity/add/test-bundle'); - $this->assertNoFieldByName("{$field_name_no_access}[$langcode][0][value]", '', t('Widget is not displayed if field access is denied.')); + $this->assertNoFieldByName("{$field_name_no_access}[$locale][0][value]", '', t('Widget is not displayed if field access is denied.')); // Create entity. - $edit = array("{$field_name}[$langcode][0][value]" => 1); + $edit = array("{$field_name}[$locale][0][value]" => 1); $this->drupalPost(NULL, $edit, t('Save')); preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match); $id = $match[1]; // Check that the default value was saved. $entity = field_test_entity_test_load($id); - $this->assertEqual($entity->{$field_name_no_access}[$langcode][0]['value'], 99, t('Default value was saved for the field with no edit access.')); - $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], 1, t('Entered value vas saved for the field with edit access.')); + $this->assertEqual($entity->{$field_name_no_access}[$locale][0]['value'], 99, t('Default value was saved for the field with no edit access.')); + $this->assertEqual($entity->{$field_name}[$locale][0]['value'], 1, t('Entered value vas saved for the field with edit access.')); // Create a new revision. - $edit = array("{$field_name}[$langcode][0][value]" => 2, 'revision' => TRUE); + $edit = array("{$field_name}[$locale][0][value]" => 2, 'revision' => TRUE); $this->drupalPost('test-entity/manage/' . $id . '/edit', $edit, t('Save')); // Check that the new revision has the expected values. $entity = field_test_entity_test_load($id); - $this->assertEqual($entity->{$field_name_no_access}[$langcode][0]['value'], 99, t('New revision has the expected value for the field with no edit access.')); - $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], 2, t('New revision has the expected value for the field with edit access.')); + $this->assertEqual($entity->{$field_name_no_access}[$locale][0]['value'], 99, t('New revision has the expected value for the field with no edit access.')); + $this->assertEqual($entity->{$field_name}[$locale][0]['value'], 2, t('New revision has the expected value for the field with edit access.')); // Check that the revision is also saved in the revisions table. $entity = field_test_entity_test_load($id, $entity->ftvid); - $this->assertEqual($entity->{$field_name_no_access}[$langcode][0]['value'], 99, t('New revision has the expected value for the field with no edit access.')); - $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], 2, t('New revision has the expected value for the field with edit access.')); + $this->assertEqual($entity->{$field_name_no_access}[$locale][0]['value'], 99, t('New revision has the expected value for the field with no edit access.')); + $this->assertEqual($entity->{$field_name}[$locale][0]['value'], 2, t('New revision has the expected value for the field with edit access.')); } /** @@ -2204,18 +2204,18 @@ class FieldCrudTestCase extends FieldTestCase { // Save an entity with data for the field $entity = field_test_create_stub_entity(0, 0, $instance['bundle']); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $values[0]['value'] = mt_rand(1, 127); - $entity->{$field['field_name']}[$langcode] = $values; + $entity->{$field['field_name']}[$locale] = $values; $entity_type = 'test_entity'; field_attach_insert('test_entity', $entity); // Verify the field is present on load $entity = field_test_create_stub_entity(0, 0, $this->instance_definition['bundle']); field_attach_load($entity_type, array(0 => $entity)); - $this->assertIdentical(count($entity->{$field['field_name']}[$langcode]), count($values), "Data in previously deleted field saves and loads correctly"); + $this->assertIdentical(count($entity->{$field['field_name']}[$locale]), count($values), "Data in previously deleted field saves and loads correctly"); foreach ($values as $delta => $value) { - $this->assertEqual($entity->{$field['field_name']}[$langcode][$delta]['value'], $values[$delta]['value'], "Data in previously deleted field saves and loads correctly"); + $this->assertEqual($entity->{$field['field_name']}[$locale][$delta]['value'], $values[$delta]['value'], "Data in previously deleted field saves and loads correctly"); } } @@ -2662,9 +2662,9 @@ class FieldTranslationsTestCase extends FieldTestCase { variable_set('field_test_field_available_languages_alter', TRUE); $enabled_languages = field_content_languages(); $available_languages = field_available_languages($this->entity_type, $this->field); - foreach ($available_languages as $delta => $langcode) { - if ($langcode != 'xx' && $langcode != 'en') { - $this->assertTrue(in_array($langcode, $enabled_languages), t('%language is an enabled language.', array('%language' => $langcode))); + foreach ($available_languages as $delta => $locale) { + if ($locale != 'xx' && $locale != 'en') { + $this->assertTrue(in_array($locale, $enabled_languages), t('%language is an enabled language.', array('%language' => $locale))); } } $this->assertTrue(in_array('xx', $available_languages), t('%language was made available.', array('%language' => 'xx'))); @@ -2697,19 +2697,19 @@ class FieldTranslationsTestCase extends FieldTestCase { } // For each given language provide some random values. - foreach ($languages as $langcode) { + foreach ($languages as $locale) { for ($delta = 0; $delta < $this->field['cardinality']; $delta++) { - $values[$langcode][$delta]['value'] = mt_rand(1, 127); + $values[$locale][$delta]['value'] = mt_rand(1, 127); } } $entity->{$this->field_name} = $values; $results = _field_invoke('test_op', $entity_type, $entity); - foreach ($results as $langcode => $result) { - $hash = hash('sha256', serialize(array($entity_type, $entity, $this->field_name, $langcode, $values[$langcode]))); + foreach ($results as $locale => $result) { + $hash = hash('sha256', serialize(array($entity_type, $entity, $this->field_name, $locale, $values[$locale]))); // Check whether the parameters passed to _field_invoke() were correctly // forwarded to the callback function. - $this->assertEqual($hash, $result, t('The result for %language is correctly stored.', array('%language' => $langcode))); + $this->assertEqual($hash, $result, t('The result for %language is correctly stored.', array('%language' => $locale))); } $this->assertEqual(count($results), count($available_languages), t('No unavailable language has been processed.')); @@ -2743,19 +2743,19 @@ class FieldTranslationsTestCase extends FieldTestCase { // For each given language provide some random values. $language_count = count($languages); for ($i = 0; $i < $language_count; ++$i) { - $langcode = $languages[$i]; + $locale = $languages[$i]; // Avoid to populate at least one field translation to check that // per-entity language suggestions work even when available field values // are different for each language. if ($i !== $id) { for ($delta = 0; $delta < $this->field['cardinality']; $delta++) { - $values[$id][$langcode][$delta]['value'] = mt_rand(1, 127); + $values[$id][$locale][$delta]['value'] = mt_rand(1, 127); } } // Ensure that a language for which there is no field translation is // used as display language to prepare per-entity language suggestions. elseif (!isset($display_language)) { - $display_language = $langcode; + $display_language = $locale; } } @@ -2768,12 +2768,12 @@ class FieldTranslationsTestCase extends FieldTestCase { $grouped_results = _field_invoke_multiple('test_op_multiple', $entity_type, $entities); foreach ($grouped_results as $id => $results) { - foreach ($results as $langcode => $result) { - if (isset($values[$id][$langcode])) { - $hash = hash('sha256', serialize(array($entity_type, $entities[$id], $this->field_name, $langcode, $values[$id][$langcode]))); + foreach ($results as $locale => $result) { + if (isset($values[$id][$locale])) { + $hash = hash('sha256', serialize(array($entity_type, $entities[$id], $this->field_name, $locale, $values[$id][$locale]))); // Check whether the parameters passed to _field_invoke_multiple() // were correctly forwarded to the callback function. - $this->assertEqual($hash, $result, t('The result for entity %id/%language is correctly stored.', array('%id' => $id, '%language' => $langcode))); + $this->assertEqual($hash, $result, t('The result for entity %id/%language is correctly stored.', array('%id' => $id, '%language' => $locale))); } } $this->assertEqual(count($results), count($available_languages), t('No unavailable language has been processed for entity %id.', array('%id' => $id))); @@ -2782,8 +2782,8 @@ class FieldTranslationsTestCase extends FieldTestCase { $null = NULL; $grouped_results = _field_invoke_multiple('test_op_multiple', $entity_type, $entities, $null, $null, $options); foreach ($grouped_results as $id => $results) { - foreach ($results as $langcode => $result) { - $this->assertTrue(isset($options['language'][$id]), t('The result language %language for entity %id was correctly suggested (display language: %display_language).', array('%id' => $id, '%language' => $langcode, '%display_language' => $display_language))); + foreach ($results as $locale => $result) { + $this->assertTrue(isset($options['language'][$id]), t('The result language %language for entity %id was correctly suggested (display language: %display_language).', array('%id' => $id, '%language' => $locale, '%display_language' => $display_language))); } } } @@ -2805,8 +2805,8 @@ class FieldTranslationsTestCase extends FieldTestCase { $field_translations = array(); $available_languages = field_available_languages($entity_type, $this->field); $this->assertTrue(count($available_languages) > 1, t('Field is translatable.')); - foreach ($available_languages as $langcode) { - $field_translations[$langcode] = $this->_generateTestFieldValues($this->field['cardinality']); + foreach ($available_languages as $locale) { + $field_translations[$locale] = $this->_generateTestFieldValues($this->field['cardinality']); } // Save and reload the field translations. @@ -2816,12 +2816,12 @@ class FieldTranslationsTestCase extends FieldTestCase { field_attach_load($entity_type, array($eid => $entity)); // Check if the correct values were saved/loaded. - foreach ($field_translations as $langcode => $items) { + foreach ($field_translations as $locale => $items) { $result = TRUE; foreach ($items as $delta => $item) { - $result = $result && $item['value'] == $entity->{$this->field_name}[$langcode][$delta]['value']; + $result = $result && $item['value'] == $entity->{$this->field_name}[$locale][$delta]['value']; } - $this->assertTrue($result, t('%language translation correctly handled.', array('%language' => $langcode))); + $this->assertTrue($result, t('%language translation correctly handled.', array('%language' => $locale))); } } @@ -2863,11 +2863,11 @@ class FieldTranslationsTestCase extends FieldTestCase { do { // Index 0 is reserved for the requested language, this way we ensure // that no field is actually populated with it. - $langcode = $enabled_languages[mt_rand(1, count($enabled_languages) - 1)]; + $locale = $enabled_languages[mt_rand(1, count($enabled_languages) - 1)]; } - while (isset($languages[$langcode])); - $languages[$langcode] = TRUE; - $entity->{$field_name}[$langcode] = $this->_generateTestFieldValues($field['cardinality']); + while (isset($languages[$locale])); + $languages[$locale] = TRUE; + $entity->{$field_name}[$locale] = $this->_generateTestFieldValues($field['cardinality']); } // Test multiple-fields display languages for untranslatable entities. @@ -2887,17 +2887,17 @@ class FieldTranslationsTestCase extends FieldTestCase { foreach ($instances as $instance) { $field_name = $instance['field_name']; - $langcode = $display_language[$field_name]; + $locale = $display_language[$field_name]; // As the requested language was not assinged to any field, if the // returned language is defined for the current field, core fallback rules // were successfully applied. - $this->assertTrue(isset($entity->{$field_name}[$langcode]) && $langcode != $requested_language, t('The display language for the field %field_name is %language.', array('%field_name' => $field_name, '%language' => $langcode))); + $this->assertTrue(isset($entity->{$field_name}[$locale]) && $locale != $requested_language, t('The display language for the field %field_name is %language.', array('%field_name' => $field_name, '%language' => $locale))); } // Test single-field display language. drupal_static_reset('field_language'); - $langcode = field_language($entity_type, $entity, $this->field_name, $requested_language); - $this->assertTrue(isset($entity->{$this->field_name}[$langcode]) && $langcode != $requested_language, t('The display language for the (single) field %field_name is %language.', array('%field_name' => $field_name, '%language' => $langcode))); + $locale = field_language($entity_type, $entity, $this->field_name, $requested_language); + $this->assertTrue(isset($entity->{$this->field_name}[$locale]) && $locale != $requested_language, t('The display language for the (single) field %field_name is %language.', array('%field_name' => $field_name, '%language' => $locale))); // Test field_language() basic behavior without language fallback. variable_set('field_test_language_fallback', FALSE); @@ -2924,14 +2924,14 @@ class FieldTranslationsTestCase extends FieldTestCase { // Store the field translations. $entity->is_new = TRUE; - foreach ($available_languages as $langcode => $value) { - $entity->{$field_name}[$langcode][0]['value'] = $value + 1; + foreach ($available_languages as $locale => $value) { + $entity->{$field_name}[$locale][0]['value'] = $value + 1; } field_test_entity_save($entity); // Create a new revision. - $langcode = field_valid_language(NULL); - $edit = array("{$field_name}[$langcode][0][value]" => $entity->{$field_name}[$langcode][0]['value'], 'revision' => TRUE); + $locale = field_valid_language(NULL); + $edit = array("{$field_name}[$locale][0][value]" => $entity->{$field_name}[$locale][0]['value'], 'revision' => TRUE); $this->drupalPost('test-entity/manage/' . $eid . '/edit', $edit, t('Save')); // Check translation revisions. @@ -2946,9 +2946,9 @@ class FieldTranslationsTestCase extends FieldTestCase { private function checkTranslationRevisions($eid, $evid, $available_languages) { $field_name = $this->field['field_name']; $entity = field_test_entity_test_load($eid, $evid); - foreach ($available_languages as $langcode => $value) { - $passed = isset($entity->{$field_name}[$langcode]) && $entity->{$field_name}[$langcode][0]['value'] == $value + 1; - $this->assertTrue($passed, t('The @language translation for revision @revision was correctly stored', array('@language' => $langcode, '@revision' => $entity->ftvid))); + foreach ($available_languages as $locale => $value) { + $passed = isset($entity->{$field_name}[$locale]) && $entity->{$field_name}[$locale][0]['value'] == $value + 1; + $this->assertTrue($passed, t('The @language translation for revision @revision was correctly stored', array('@language' => $locale, '@revision' => $entity->ftvid))); } } } diff --git a/modules/field/tests/field_test.field.inc b/modules/field/tests/field_test.field.inc index b8a2939..2ba3dc3 100644 --- a/modules/field/tests/field_test.field.inc +++ b/modules/field/tests/field_test.field.inc @@ -57,7 +57,7 @@ function field_test_field_update_forbid($field, $prior_field, $has_data) { /** * Implements hook_field_load(). */ -function field_test_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) { +function field_test_field_load($entity_type, $entities, $field, $instances, $locale, &$items, $age) { foreach ($items as $id => $item) { // To keep the test non-intrusive, only act for instances with the // test_hook_field_load setting explicitly set to TRUE. @@ -78,10 +78,10 @@ function field_test_field_load($entity_type, $entities, $field, $instances, $lan * Possible error codes: * - 'field_test_invalid': The value is invalid. */ -function field_test_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) { +function field_test_field_validate($entity_type, $entity, $field, $instance, $locale, $items, &$errors) { foreach ($items as $delta => $item) { if ($item['value'] == -1) { - $errors[$field['field_name']][$langcode][$delta][] = array( + $errors[$field['field_name']][$locale][$delta][] = array( 'error' => 'field_test_invalid', 'message' => t('%name does not accept the value -1.', array('%name' => $instance['label'])), ); @@ -154,7 +154,7 @@ function field_test_field_widget_info() { /** * Implements hook_field_widget_form(). */ -function field_test_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) { +function field_test_field_widget_form(&$form, &$form_state, $field, $instance, $locale, $items, $delta, $element) { switch ($instance['widget']['type']) { case 'test_field_widget': $element += array( @@ -314,7 +314,7 @@ function field_test_field_formatter_settings_summary($field, $instance, $view_mo /** * Implements hook_field_formatter_prepare_view(). */ -function field_test_field_formatter_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $displays) { +function field_test_field_formatter_prepare_view($entity_type, $entities, $field, $instances, $locale, &$items, $displays) { foreach ($items as $id => $item) { // To keep the test non-intrusive, only act on the // 'field_test_with_prepare_view' formatter. @@ -332,7 +332,7 @@ function field_test_field_formatter_prepare_view($entity_type, $entities, $field /** * Implements hook_field_formatter_view(). */ -function field_test_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { +function field_test_field_formatter_view($entity_type, $entity, $field, $instance, $locale, $items, $display) { $element = array(); $settings = $display['settings']; diff --git a/modules/field/tests/field_test.module b/modules/field/tests/field_test.module index 4075296..2f63a0e 100644 --- a/modules/field/tests/field_test.module +++ b/modules/field/tests/field_test.module @@ -75,8 +75,8 @@ function field_test_menu() { * * This simulates a field operation callback to be invoked by _field_invoke(). */ -function field_test_field_test_op($entity_type, $entity, $field, $instance, $langcode, &$items) { - return array($langcode => hash('sha256', serialize(array($entity_type, $entity, $field['field_name'], $langcode, $items)))); +function field_test_field_test_op($entity_type, $entity, $field, $instance, $locale, &$items) { + return array($locale => hash('sha256', serialize(array($entity_type, $entity, $field['field_name'], $locale, $items)))); } /** @@ -85,7 +85,7 @@ function field_test_field_test_op($entity_type, $entity, $field, $instance, $lan * This simulates a multiple field operation callback to be invoked by * _field_invoke_multiple(). */ -function field_test_field_test_op_multiple($entity_type, $entities, $field, $instances, $langcode, &$items) { +function field_test_field_test_op_multiple($entity_type, $entities, $field, $instances, $locale, &$items) { $result = array(); foreach ($entities as $id => $entity) { // Entities, instances and items are assumed to be consistently grouped by @@ -93,7 +93,7 @@ function field_test_field_test_op_multiple($entity_type, $entities, $field, $ins // by entity id. If they are grouped correctly, one entity, one instance and // one array of items should be available for each entity id. $field_name = $instances[$id]['field_name']; - $result[$id] = array($langcode => hash('sha256', serialize(array($entity_type, $entity, $field_name, $langcode, $items[$id])))); + $result[$id] = array($locale => hash('sha256', serialize(array($entity_type, $entity, $field_name, $locale, $items[$id])))); } return $result; } diff --git a/modules/field/tests/field_test.storage.inc b/modules/field/tests/field_test.storage.inc index 3ca322d..2f58c20 100644 --- a/modules/field/tests/field_test.storage.inc +++ b/modules/field/tests/field_test.storage.inc @@ -150,8 +150,8 @@ function field_test_field_storage_write($entity_type, $entity, $op, $fields) { } } - foreach ($field_languages as $langcode) { - $items = (array) $entity->{$field_name}[$langcode]; + foreach ($field_languages as $locale) { + $items = (array) $entity->{$field_name}[$locale]; $delta_count = 0; foreach ($items as $delta => $item) { $row = (object) array( @@ -162,7 +162,7 @@ function field_test_field_storage_write($entity_type, $entity, $op, $fields) { 'bundle' => $bundle, 'delta' => $delta, 'deleted' => FALSE, - 'language' => $langcode, + 'language' => $locale, ); foreach ($field['columns'] as $column => $attributes) { $row->{$column} = isset($item[$column]) ? $item[$column] : NULL; diff --git a/modules/field_ui/field_ui.test b/modules/field_ui/field_ui.test index 5d2ff9b..7890d00 100644 --- a/modules/field_ui/field_ui.test +++ b/modules/field_ui/field_ui.test @@ -298,10 +298,10 @@ class FieldUIManageFieldsTestCase extends FieldUITestCase { ); field_create_instance($instance); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $admin_path = 'admin/structure/types/manage/' . $this->hyphen_type . '/fields/' . $field_name; - $element_id = "edit-$field_name-$langcode-0-value"; - $element_name = "{$field_name}[$langcode][0][value]"; + $element_id = "edit-$field_name-$locale-0-value"; + $element_name = "{$field_name}[$locale][0][value]"; $this->drupalGet($admin_path); $this->assertFieldById($element_id, '', t('The default value widget was empty.')); diff --git a/modules/file/file.field.inc b/modules/file/file.field.inc index 2af3cb6..c00715f 100644 --- a/modules/file/file.field.inc +++ b/modules/file/file.field.inc @@ -166,7 +166,7 @@ function _file_generic_settings_file_directory_validate($element, &$form_state) /** * Implements hook_field_load(). */ -function file_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) { +function file_field_load($entity_type, $entities, $field, $instances, $locale, &$items, $age) { $fids = array(); foreach ($entities as $id => $entity) { @@ -195,7 +195,7 @@ function file_field_load($entity_type, $entities, $field, $instances, $langcode, /** * Implements hook_field_prepare_view(). */ -function file_field_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items) { +function file_field_prepare_view($entity_type, $entities, $field, $instances, $locale, &$items) { // Remove files specified to not be displayed. foreach ($entities as $id => $entity) { foreach ($items[$id] as $delta => $item) { @@ -211,7 +211,7 @@ function file_field_prepare_view($entity_type, $entities, $field, $instances, $l /** * Implements hook_field_presave(). */ -function file_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) { +function file_field_presave($entity_type, $entity, $field, $instance, $locale, &$items) { // Make sure that each file which will be saved with this object has a // permanent status, so that it will not be removed when temporary files are // cleaned up. @@ -227,7 +227,7 @@ function file_field_presave($entity_type, $entity, $field, $instance, $langcode, /** * Implements hook_field_insert(). */ -function file_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) { +function file_field_insert($entity_type, $entity, $field, $instance, $locale, &$items) { list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity); // Add a new usage of each uploaded file. @@ -242,7 +242,7 @@ function file_field_insert($entity_type, $entity, $field, $instance, $langcode, * * Checks for files that have been removed from the object. */ -function file_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) { +function file_field_update($entity_type, $entity, $field, $instance, $locale, &$items) { list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity); // On new revisions, all files are considered to be a new usage and no @@ -267,8 +267,8 @@ function file_field_update($entity_type, $entity, $field, $instance, $langcode, // Compare the original field values with the ones that are being saved. $original_fids = array(); - if (!empty($original->{$field['field_name']}[$langcode])) { - foreach ($original->{$field['field_name']}[$langcode] as $original_item) { + if (!empty($original->{$field['field_name']}[$locale])) { + foreach ($original->{$field['field_name']}[$locale] as $original_item) { $original_fids[] = $original_item['fid']; if (isset($original_item['fid']) && !in_array($original_item['fid'], $current_fids)) { // Decrement the file usage count by 1 and delete the file if possible. @@ -289,7 +289,7 @@ function file_field_update($entity_type, $entity, $field, $instance, $langcode, /** * Implements hook_field_delete(). */ -function file_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items) { +function file_field_delete($entity_type, $entity, $field, $instance, $locale, &$items) { list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity); // Delete all file usages within this entity. @@ -301,7 +301,7 @@ function file_field_delete($entity_type, $entity, $field, $instance, $langcode, /** * Implements hook_field_delete_revision(). */ -function file_field_delete_revision($entity_type, $entity, $field, $instance, $langcode, &$items) { +function file_field_delete_revision($entity_type, $entity, $field, $instance, $locale, &$items) { list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity); foreach ($items as $delta => $item) { // Decrement the file usage count by 1 and delete the file if possible. @@ -439,7 +439,7 @@ function file_field_widget_settings_form($field, $instance) { /** * Implements hook_field_widget_form(). */ -function file_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) { +function file_field_widget_form(&$form, &$form_state, $field, $instance, $locale, $items, $delta, $element) { $defaults = array( 'fid' => 0, @@ -450,7 +450,7 @@ function file_field_widget_form(&$form, &$form_state, $field, $instance, $langco // Retrieve any values set in $form_state, as will be the case during Ajax // rebuilds of this form. if (isset($form_state['values'])) { - $path = array_merge($element['#field_parents'], array($field['field_name'], $langcode)); + $path = array_merge($element['#field_parents'], array($field['field_name'], $locale)); $path_exists = FALSE; $values = drupal_array_get_nested_value($form_state['values'], $path, $path_exists); if ($path_exists) { @@ -940,7 +940,7 @@ function theme_file_upload_help($variables) { /** * Implements hook_field_formatter_view(). */ -function file_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { +function file_field_formatter_view($entity_type, $entity, $field, $instance, $locale, $items, $display) { $element = array(); switch ($display['type']) { diff --git a/modules/file/tests/file.test b/modules/file/tests/file.test index 947247d..2b586c0 100644 --- a/modules/file/tests/file.test +++ b/modules/file/tests/file.test @@ -113,7 +113,7 @@ class FileFieldTestCase extends DrupalWebTestCase { * Upload a file to a node. */ function uploadNodeFile($file, $field_name, $nid_or_type, $new_revision = TRUE) { - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $edit = array( "title" => $this->randomName(), 'revision' => (string) (int) $new_revision, @@ -133,7 +133,7 @@ class FileFieldTestCase extends DrupalWebTestCase { } // Attach a file to the node. - $edit['files[' . $field_name . '_' . $langcode . '_0]'] = drupal_realpath($file->uri); + $edit['files[' . $field_name . '_' . $locale . '_0]'] = drupal_realpath($file->uri); $this->drupalPost("node/$nid/edit", $edit, t('Save')); return $nid; @@ -757,7 +757,7 @@ class FileFieldValidateTestCase extends FileFieldTestCase { $test_file = $this->getTestFile('text'); // Try to post a new node without uploading a file. - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $edit = array("title" => $this->randomName()); $this->drupalPost('node/add/' . $type_name, $edit, t('Save')); $this->assertRaw(t('!title field is required.', array('!title' => $instance['label'])), t('Node save failed when required file field was empty.')); diff --git a/modules/filter/filter.api.php b/modules/filter/filter.api.php index 6675e4a..a110e48 100644 --- a/modules/filter/filter.api.php +++ b/modules/filter/filter.api.php @@ -189,7 +189,7 @@ function hook_filter_FILTER_settings($form, &$form_state, $filter, $format, $def * The filter object containing settings for the given format. * @param $format * The text format object assigned to the text to be filtered. - * @param $langcode + * @param $locale * The language code of the text to be filtered. * @param $cache * A Boolean indicating whether the filtered text is going to be cached in @@ -200,7 +200,7 @@ function hook_filter_FILTER_settings($form, &$form_state, $filter, $format, $def * @return * The prepared, escaped text. */ -function hook_filter_FILTER_prepare($text, $filter, $format, $langcode, $cache, $cache_id) { +function hook_filter_FILTER_prepare($text, $filter, $format, $locale, $cache, $cache_id) { // Escape and tags. $text = preg_replace('|(.+?)|se', "[codefilter_code]$1[/codefilter_code]", $text); return $text; @@ -222,7 +222,7 @@ function hook_filter_FILTER_prepare($text, $filter, $format, $langcode, $cache, * The filter object containing settings for the given format. * @param $format * The text format object assigned to the text to be filtered. - * @param $langcode + * @param $locale * The language code of the text to be filtered. * @param $cache * A Boolean indicating whether the filtered text is going to be cached in @@ -233,7 +233,7 @@ function hook_filter_FILTER_prepare($text, $filter, $format, $langcode, $cache, * @return * The filtered text. */ -function hook_filter_FILTER_process($text, $filter, $format, $langcode, $cache, $cache_id) { +function hook_filter_FILTER_process($text, $filter, $format, $locale, $cache, $cache_id) { $text = preg_replace('|\[codefilter_code\](.+?)\[/codefilter_code\]|se', "
$1
", $text); return $text; diff --git a/modules/filter/filter.module b/modules/filter/filter.module index 66fadcb..398ac46 100644 --- a/modules/filter/filter.module +++ b/modules/filter/filter.module @@ -704,7 +704,7 @@ function filter_list_format($format_id) { * @param $format_id * The format id of the text to be filtered. If no format is assigned, the * fallback format will be used. - * @param $langcode + * @param $locale * Optional: the language code of the text to be filtered, e.g. 'en' for * English. This allows filters to be language aware so language specific * text replacement can be implemented. @@ -715,7 +715,7 @@ function filter_list_format($format_id) { * * @ingroup sanitization */ -function check_markup($text, $format_id = NULL, $langcode = '', $cache = FALSE) { +function check_markup($text, $format_id = NULL, $locale = '', $cache = FALSE) { if (!isset($format_id)) { $format_id = filter_fallback_format(); } @@ -729,7 +729,7 @@ function check_markup($text, $format_id = NULL, $langcode = '', $cache = FALSE) $cache = $cache && !empty($format->cache); $cache_id = ''; if ($cache) { - $cache_id = $format->format . ':' . $langcode . ':' . hash('sha256', $text); + $cache_id = $format->format . ':' . $locale . ':' . hash('sha256', $text); if ($cached = cache_get($cache_id, 'cache_filter')) { return $cached->data; } @@ -747,7 +747,7 @@ function check_markup($text, $format_id = NULL, $langcode = '', $cache = FALSE) foreach ($filters as $name => $filter) { if ($filter->status && isset($filter_info[$name]['prepare callback']) && function_exists($filter_info[$name]['prepare callback'])) { $function = $filter_info[$name]['prepare callback']; - $text = $function($text, $filter, $format, $langcode, $cache, $cache_id); + $text = $function($text, $filter, $format, $locale, $cache, $cache_id); } } @@ -755,7 +755,7 @@ function check_markup($text, $format_id = NULL, $langcode = '', $cache = FALSE) foreach ($filters as $name => $filter) { if ($filter->status && isset($filter_info[$name]['process callback']) && function_exists($filter_info[$name]['process callback'])) { $function = $filter_info[$name]['process callback']; - $text = $function($text, $filter, $format, $langcode, $cache, $cache_id); + $text = $function($text, $filter, $format, $locale, $cache, $cache_id); } } diff --git a/modules/filter/filter.test b/modules/filter/filter.test index a3d1bde..a1b42f0 100644 --- a/modules/filter/filter.test +++ b/modules/filter/filter.test @@ -353,10 +353,10 @@ class FilterAdminTestCase extends DrupalWebTestCase { $text = $body . '' . $extra_text . ''; $edit = array(); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $edit["title"] = $this->randomName(); - $edit["body[$langcode][0][value]"] = $text; - $edit["body[$langcode][0][format]"] = $filtered; + $edit["body[$locale][0][value]"] = $text; + $edit["body[$locale][0][format]"] = $filtered; $this->drupalPost('node/add/page', $edit, t('Save')); $this->assertRaw(t('Basic page %title has been created.', array('%title' => $edit["title"])), t('Filtered node created.')); @@ -368,7 +368,7 @@ class FilterAdminTestCase extends DrupalWebTestCase { // Use plain text and see if it escapes all tags, whether allowed or not. $edit = array(); - $edit["body[$langcode][0][format]"] = $plain; + $edit["body[$locale][0][format]"] = $plain; $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save')); $this->drupalGet('node/' . $node->nid); $this->assertText(check_plain($text), t('The "Plain text" text format escapes all HTML tags.')); @@ -481,9 +481,9 @@ class FilterFormatAccessTestCase extends DrupalWebTestCase { // the disallowed format does not. $this->drupalLogin($this->web_user); $this->drupalGet('node/add/page'); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $elements = $this->xpath('//select[@name=:name]/option', array( - ':name' => "body[$langcode][0][format]", + ':name' => "body[$locale][0][format]", ':option' => $this->allowed_format->format, )); $options = array(); @@ -525,10 +525,10 @@ class FilterFormatAccessTestCase extends DrupalWebTestCase { * forced to choose a new format before saving the page. */ function testFormatWidgetPermissions() { - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $title_key = "title"; - $body_value_key = "body[$langcode][0][value]"; - $body_format_key = "body[$langcode][0][format]"; + $body_value_key = "body[$locale][0][value]"; + $body_format_key = "body[$locale][0][format]"; // Create node to edit. $this->drupalLogin($this->admin_user); diff --git a/modules/forum/forum.module b/modules/forum/forum.module index c58b5c9..4f35732 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -287,16 +287,16 @@ function forum_node_view($node, $view_mode) { */ function forum_node_validate($node, $form) { if (_forum_node_check_node_type($node)) { - $langcode = $form['taxonomy_forums']['#language']; + $locale = $form['taxonomy_forums']['#language']; // vocabulary is selected, not a "container" term. - if (!empty($node->taxonomy_forums[$langcode])) { + if (!empty($node->taxonomy_forums[$locale])) { // Extract the node's proper topic ID. $containers = variable_get('forum_containers', array()); - foreach ($node->taxonomy_forums[$langcode] as $delta => $item) { + foreach ($node->taxonomy_forums[$locale] as $delta => $item) { // If no term was selected (e.g. when no terms exist yet), remove the // item. if (empty($item['tid'])) { - unset($node->taxonomy_forums[$langcode][$delta]); + unset($node->taxonomy_forums[$locale][$delta]); continue; } $term = taxonomy_term_load($item['tid']); @@ -326,13 +326,13 @@ function forum_node_presave($node) { // Make sure all fields are set properly: $node->icon = !empty($node->icon) ? $node->icon : ''; reset($node->taxonomy_forums); - $langcode = key($node->taxonomy_forums); - if (!empty($node->taxonomy_forums[$langcode])) { - $node->forum_tid = $node->taxonomy_forums[$langcode][0]['tid']; + $locale = key($node->taxonomy_forums); + if (!empty($node->taxonomy_forums[$locale])) { + $node->forum_tid = $node->taxonomy_forums[$locale][0]['tid']; $old_tid = db_query_range("SELECT f.tid FROM {forum} f INNER JOIN {node} n ON f.vid = n.vid WHERE n.nid = :nid ORDER BY f.vid DESC", 0, 1, array(':nid' => $node->nid))->fetchField(); if ($old_tid && isset($node->forum_tid) && ($node->forum_tid != $old_tid) && !empty($node->shadow)) { // A shadow copy needs to be created. Retain new term and add old term. - $node->taxonomy_forums[$langcode][] = array('tid' => $old_tid); + $node->taxonomy_forums[$locale][] = array('tid' => $old_tid); } } } @@ -598,16 +598,16 @@ function forum_form_alter(&$form, $form_state, $form_id) { } } if (!empty($form['#node_edit_form']) && isset($form['taxonomy_forums'])) { - $langcode = $form['taxonomy_forums']['#language']; + $locale = $form['taxonomy_forums']['#language']; // Make the vocabulary required for 'real' forum-nodes. - $form['taxonomy_forums'][$langcode]['#required'] = TRUE; - $form['taxonomy_forums'][$langcode]['#multiple'] = FALSE; - if (empty($form['taxonomy_forums'][$langcode]['#default_value'])) { + $form['taxonomy_forums'][$locale]['#required'] = TRUE; + $form['taxonomy_forums'][$locale]['#multiple'] = FALSE; + if (empty($form['taxonomy_forums'][$locale]['#default_value'])) { // If there is no default forum already selected, try to get the forum // ID from the URL (e.g., if we are on a page like node/add/forum/2, we // expect "2" to be the ID of the forum that was requested). $requested_forum_id = arg(3); - $form['taxonomy_forums'][$langcode]['#default_value'] = is_numeric($requested_forum_id) ? $requested_forum_id : ''; + $form['taxonomy_forums'][$locale]['#default_value'] = is_numeric($requested_forum_id) ? $requested_forum_id : ''; } } } diff --git a/modules/forum/forum.test b/modules/forum/forum.test index 1dc45c6..bba1d78 100644 --- a/modules/forum/forum.test +++ b/modules/forum/forum.test @@ -353,10 +353,10 @@ class ForumTestCase extends DrupalWebTestCase { $title = $this->randomName(20); $body = $this->randomName(200); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $edit = array( "title" => $title, - "body[$langcode][0][value]" => $body, + "body[$locale][0][value]" => $body, ); $tid = $forum['tid']; @@ -444,11 +444,11 @@ class ForumTestCase extends DrupalWebTestCase { if ($response == 200) { // Edit forum node (including moving it to another forum). $edit = array(); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $edit["title"] = 'node/' . $node->nid; - $edit["body[$langcode][0][value]"] = $this->randomName(256); + $edit["body[$locale][0][value]"] = $this->randomName(256); // Assume the topic is initially associated with $forum. - $edit["taxonomy_forums[$langcode]"] = $this->root_forum['tid']; + $edit["taxonomy_forums[$locale]"] = $this->root_forum['tid']; $edit['shadow'] = TRUE; $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save')); $this->assertRaw(t('Forum topic %title has been updated.', array('%title' => $edit["title"])), t('Forum node was edited')); diff --git a/modules/image/image.field.inc b/modules/image/image.field.inc index 43e118a..1b9b38e 100644 --- a/modules/image/image.field.inc +++ b/modules/image/image.field.inc @@ -181,14 +181,14 @@ function _image_field_resolution_validate($element, &$form_state) { /** * Implements hook_field_load(). */ -function image_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) { - file_field_load($entity_type, $entities, $field, $instances, $langcode, $items, $age); +function image_field_load($entity_type, $entities, $field, $instances, $locale, &$items, $age) { + file_field_load($entity_type, $entities, $field, $instances, $locale, $items, $age); } /** * Implements hook_field_prepare_view(). */ -function image_field_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items) { +function image_field_prepare_view($entity_type, $entities, $field, $instances, $locale, &$items) { // If there are no files specified at all, use the default. foreach ($entities as $id => $entity) { if (empty($items[$id]) && $field['settings']['default_image']) { @@ -206,36 +206,36 @@ function image_field_prepare_view($entity_type, $entities, $field, $instances, $ /** * Implements hook_field_presave(). */ -function image_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) { - file_field_presave($entity_type, $entity, $field, $instance, $langcode, $items); +function image_field_presave($entity_type, $entity, $field, $instance, $locale, &$items) { + file_field_presave($entity_type, $entity, $field, $instance, $locale, $items); } /** * Implements hook_field_insert(). */ -function image_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) { - file_field_insert($entity_type, $entity, $field, $instance, $langcode, $items); +function image_field_insert($entity_type, $entity, $field, $instance, $locale, &$items) { + file_field_insert($entity_type, $entity, $field, $instance, $locale, $items); } /** * Implements hook_field_update(). */ -function image_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) { - file_field_update($entity_type, $entity, $field, $instance, $langcode, $items); +function image_field_update($entity_type, $entity, $field, $instance, $locale, &$items) { + file_field_update($entity_type, $entity, $field, $instance, $locale, $items); } /** * Implements hook_field_delete(). */ -function image_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items) { - file_field_delete($entity_type, $entity, $field, $instance, $langcode, $items); +function image_field_delete($entity_type, $entity, $field, $instance, $locale, &$items) { + file_field_delete($entity_type, $entity, $field, $instance, $locale, $items); } /** * Implements hook_field_delete_revision(). */ -function image_field_delete_revision($entity_type, $entity, $field, $instance, $langcode, &$items) { - file_field_delete_revision($entity_type, $entity, $field, $instance, $langcode, $items); +function image_field_delete_revision($entity_type, $entity, $field, $instance, $locale, &$items) { + file_field_delete_revision($entity_type, $entity, $field, $instance, $locale, $items); } /** @@ -291,12 +291,12 @@ function image_field_widget_settings_form($field, $instance) { /** * Implements hook_field_widget_form(). */ -function image_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) { +function image_field_widget_form(&$form, &$form_state, $field, $instance, $locale, $items, $delta, $element) { // Add display_field setting to field because file_field_widget_form() assumes it is set. $field['settings']['display_field'] = 0; - $elements = file_field_widget_form($form, $form_state, $field, $instance, $langcode, $items, $delta, $element); + $elements = file_field_widget_form($form, $form_state, $field, $instance, $locale, $items, $delta, $element); $settings = $instance['settings']; foreach (element_children($elements) as $delta) { @@ -488,7 +488,7 @@ function image_field_formatter_settings_summary($field, $instance, $view_mode) { /** * Implements hook_field_formatter_view(). */ -function image_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { +function image_field_formatter_view($entity_type, $entity, $field, $instance, $locale, $items, $display) { $element = array(); // Check if the formatter involves a link. diff --git a/modules/image/image.module b/modules/image/image.module index 008a365..899924f 100644 --- a/modules/image/image.module +++ b/modules/image/image.module @@ -947,12 +947,12 @@ function image_effect_definitions() { // hook_image_effect_info() includes translated strings, so each language is // cached separately. - $langcode = $language->language; + $locale = $language->language; $effects = &drupal_static(__FUNCTION__); if (!isset($effects)) { - if ($cache = cache_get("image_effects:$langcode") && !empty($cache->data)) { + if ($cache = cache_get("image_effects:$locale") && !empty($cache->data)) { $effects = $cache->data; } else { @@ -969,7 +969,7 @@ function image_effect_definitions() { } uasort($effects, '_image_effect_definitions_sort'); drupal_alter('image_effect_info', $effects); - cache_set("image_effects:$langcode", $effects); + cache_set("image_effects:$locale", $effects); } } diff --git a/modules/locale/locale.admin.inc b/modules/locale/locale.admin.inc index b0a77c5..3d9ed25 100644 --- a/modules/locale/locale.admin.inc +++ b/modules/locale/locale.admin.inc @@ -23,22 +23,22 @@ function locale_languages_overview_form() { $options = array(); $form['weight'] = array('#tree' => TRUE); - foreach ($languages as $langcode => $language) { + foreach ($languages as $locale => $language) { - $options[$langcode] = ''; + $options[$locale] = ''; if ($language->enabled) { - $enabled[] = $langcode; + $enabled[] = $locale; } - $form['weight'][$langcode] = array( + $form['weight'][$locale] = array( '#type' => 'weight', '#title' => t('Weight for @title', array('@title' => $language->name)), '#title_display' => 'invisible', '#default_value' => $language->weight, '#attributes' => array('class' => array('language-order-weight')), ); - $form['name'][$langcode] = array('#markup' => check_plain($language->name)); - $form['native'][$langcode] = array('#markup' => check_plain($language->native)); - $form['direction'][$langcode] = array('#markup' => ($language->direction == LANGUAGE_RTL ? t('Right to left') : t('Left to right'))); + $form['name'][$locale] = array('#markup' => check_plain($language->name)); + $form['native'][$locale] = array('#markup' => check_plain($language->native)); + $form['direction'][$locale] = array('#markup' => ($language->direction == LANGUAGE_RTL ? t('Right to left') : t('Left to right'))); } $form['enabled'] = array( '#type' => 'checkboxes', @@ -123,24 +123,24 @@ function locale_languages_overview_form_submit($form, &$form_state) { $url_prefixes = variable_get('locale_language_negotiation_url_part', LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX) == LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX; $enabled_count = 0; - foreach ($languages as $langcode => $language) { - if ($form_state['values']['site_default'] == $langcode || $default->language == $langcode) { + foreach ($languages as $locale => $language) { + if ($form_state['values']['site_default'] == $locale || $default->language == $locale) { // Automatically enable the default language and the language // which was default previously (because we will not get the // value from that disabled checkbox). - $form_state['values']['enabled'][$langcode] = 1; + $form_state['values']['enabled'][$locale] = 1; } // If language URL prefixes are enabled we must clear language domains and // assign a valid prefix to each non-default language. if ($url_prefixes) { $language->domain = ''; - if (empty($language->prefix) && $form_state['values']['site_default'] != $langcode) { - $language->prefix = $langcode; + if (empty($language->prefix) && $form_state['values']['site_default'] != $locale) { + $language->prefix = $locale; } } - if ($form_state['values']['enabled'][$langcode]) { + if ($form_state['values']['enabled'][$locale]) { $enabled_count++; $language->enabled = 1; } @@ -148,7 +148,7 @@ function locale_languages_overview_form_submit($form, &$form_state) { $language->enabled = 0; } - $language->weight = $form_state['values']['weight'][$langcode]; + $language->weight = $form_state['values']['weight'][$locale]; db_update('languages') ->fields(array( @@ -157,10 +157,10 @@ function locale_languages_overview_form_submit($form, &$form_state) { 'prefix' => $language->prefix, 'domain' => $language->domain, )) - ->condition('language', $langcode) + ->condition('language', $locale) ->execute(); - $languages[$langcode] = $language; + $languages[$locale] = $language; } variable_set('language_default', $languages[$form_state['values']['site_default']]); @@ -193,7 +193,7 @@ function locale_languages_predefined_form($form) { '#title' => t('Predefined language'), '#collapsible' => TRUE, ); - $form['language list']['langcode'] = array('#type' => 'select', + $form['language list']['locale'] = array('#type' => 'select', '#title' => t('Language name'), '#default_value' => key($predefined), '#options' => $predefined, @@ -228,11 +228,11 @@ function locale_languages_custom_form($form) { /** * Editing screen for a particular language. * - * @param $langcode + * @param $locale * Language code of the language to edit. */ -function locale_languages_edit_form($form, &$form_state, $langcode) { - if ($language = db_query("SELECT * FROM {languages} WHERE language = :language", array(':language' => $langcode))->fetchObject()) { +function locale_languages_edit_form($form, &$form_state, $locale) { + if ($language = db_query("SELECT * FROM {languages} WHERE language = :language", array(':language' => $locale))->fetchObject()) { _locale_languages_common_controls($form, $language); $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array( @@ -262,18 +262,18 @@ function _locale_languages_common_controls(&$form, $language = NULL) { $language = new stdClass(); } if (isset($language->language)) { - $form['langcode_view'] = array( + $form['locale_view'] = array( '#type' => 'item', '#title' => t('Language code'), '#markup' => $language->language ); - $form['langcode'] = array( + $form['locale'] = array( '#type' => 'value', '#value' => $language->language ); } else { - $form['langcode'] = array('#type' => 'textfield', + $form['locale'] = array('#type' => 'textfield', '#title' => t('Language code'), '#size' => 12, '#maxlength' => 60, @@ -323,18 +323,18 @@ function _locale_languages_common_controls(&$form, $language = NULL) { * Validate the language addition form. */ function locale_languages_predefined_form_validate($form, &$form_state) { - $langcode = $form_state['values']['langcode']; + $locale = $form_state['values']['locale']; - if (($duplicate = db_query("SELECT COUNT(*) FROM {languages} WHERE language = :language", array(':language' => $langcode))->fetchField()) != 0) { - form_set_error('langcode', t('The language %language (%code) already exists.', array('%language' => $form_state['values']['name'], '%code' => $langcode))); + if (($duplicate = db_query("SELECT COUNT(*) FROM {languages} WHERE language = :language", array(':language' => $locale))->fetchField()) != 0) { + form_set_error('locale', t('The language %language (%locale) already exists.', array('%language' => $form_state['values']['name'], '%locale' => $locale))); } if (!isset($form_state['values']['name'])) { // Predefined language selection. include_once DRUPAL_ROOT . '/includes/iso.inc'; $predefined = _locale_get_predefined_list(); - if (!isset($predefined[$langcode])) { - form_set_error('langcode', t('Invalid language code.')); + if (!isset($predefined[$locale])) { + form_set_error('locale', t('Invalid language code.')); } } else { @@ -347,23 +347,23 @@ function locale_languages_predefined_form_validate($form, &$form_state) { * Process the language addition form submission. */ function locale_languages_predefined_form_submit($form, &$form_state) { - $langcode = $form_state['values']['langcode']; + $locale = $form_state['values']['locale']; if (isset($form_state['values']['name'])) { // Custom language form. - locale_add_language($langcode, $form_state['values']['name'], $form_state['values']['native'], $form_state['values']['direction'], $form_state['values']['domain'], $form_state['values']['prefix']); + locale_add_language($locale, $form_state['values']['name'], $form_state['values']['native'], $form_state['values']['direction'], $form_state['values']['domain'], $form_state['values']['prefix']); drupal_set_message(t('The language %language has been created and can now be used. More information is available on the help screen.', array('%language' => t($form_state['values']['name']), '@locale-help' => url('admin/help/locale')))); } else { // Predefined language selection. include_once DRUPAL_ROOT . '/includes/iso.inc'; $predefined = _locale_get_predefined_list(); - locale_add_language($langcode); - drupal_set_message(t('The language %language has been created and can now be used. More information is available on the help screen.', array('%language' => t($predefined[$langcode][0]), '@locale-help' => url('admin/help/locale')))); + locale_add_language($locale); + drupal_set_message(t('The language %language has been created and can now be used. More information is available on the help screen.', array('%language' => t($predefined[$locale][0]), '@locale-help' => url('admin/help/locale')))); } // See if we have language files to import for the newly added // language, collect and import them. - if ($batch = locale_batch_by_language($langcode, '_locale_batch_language_finished')) { + if ($batch = locale_batch_by_language($locale, '_locale_batch_language_finished')) { batch_set($batch); } @@ -374,9 +374,9 @@ function locale_languages_predefined_form_submit($form, &$form_state) { * Validate the language editing form. Reused for custom language addition too. */ function locale_languages_edit_form_validate($form, &$form_state) { - // Ensure sane field values for langcode, name, and native. - if (!isset($form['langcode_view']) && preg_match('@[^a-zA-Z_-]@', $form_state['values']['langcode'])) { - form_set_error('langcode', t('%field may only contain characters a-z, underscores, or hyphens.', array('%field' => $form['langcode']['#title']))); + // Ensure sane field values for locale, name, and native. + if (!isset($form['locale_view']) && preg_match('@[^a-zA-Z_-]@', $form_state['values']['locale'])) { + form_set_error('locale', t('%field may only contain characters a-z, underscores, or hyphens.', array('%field' => $form['locale']['#title']))); } if ($form_state['values']['name'] != check_plain($form_state['values']['name'])) { form_set_error('name', t('%field cannot contain any markup.', array('%field' => $form['name']['#title']))); @@ -388,13 +388,13 @@ function locale_languages_edit_form_validate($form, &$form_state) { if (!empty($form_state['values']['domain']) && !empty($form_state['values']['prefix'])) { form_set_error('prefix', t('Domain and path prefix values should not be set at the same time.')); } - if (!empty($form_state['values']['domain']) && $duplicate = db_query("SELECT language FROM {languages} WHERE domain = :domain AND language <> :language", array(':domain' => $form_state['values']['domain'], ':language' => $form_state['values']['langcode']))->fetchField()) { + if (!empty($form_state['values']['domain']) && $duplicate = db_query("SELECT language FROM {languages} WHERE domain = :domain AND language <> :language", array(':domain' => $form_state['values']['domain'], ':language' => $form_state['values']['locale']))->fetchField()) { form_set_error('domain', t('The domain (%domain) is already tied to a language (%language).', array('%domain' => $form_state['values']['domain'], '%language' => $duplicate->language))); } - if (empty($form_state['values']['prefix']) && language_default('language') != $form_state['values']['langcode'] && empty($form_state['values']['domain'])) { + if (empty($form_state['values']['prefix']) && language_default('language') != $form_state['values']['locale'] && empty($form_state['values']['domain'])) { form_set_error('prefix', t('Only the default language can have both the domain and prefix empty.')); } - if (!empty($form_state['values']['prefix']) && $duplicate = db_query("SELECT language FROM {languages} WHERE prefix = :prefix AND language <> :language", array(':prefix' => $form_state['values']['prefix'], ':language' => $form_state['values']['langcode']))->fetchField()) { + if (!empty($form_state['values']['prefix']) && $duplicate = db_query("SELECT language FROM {languages} WHERE prefix = :prefix AND language <> :language", array(':prefix' => $form_state['values']['prefix'], ':language' => $form_state['values']['locale']))->fetchField()) { form_set_error('prefix', t('The prefix (%prefix) is already tied to a language (%language).', array('%prefix' => $form_state['values']['prefix'], '%language' => $duplicate->language))); } } @@ -411,10 +411,10 @@ function locale_languages_edit_form_submit($form, &$form_state) { 'prefix' => $form_state['values']['prefix'], 'direction' => $form_state['values']['direction'], )) - ->condition('language', $form_state['values']['langcode']) + ->condition('language', $form_state['values']['locale']) ->execute(); $default = language_default(); - if ($default->language == $form_state['values']['langcode']) { + if ($default->language == $form_state['values']['locale']) { $properties = array('name', 'native', 'direction', 'enabled', 'plurals', 'formula', 'domain', 'prefix', 'weight'); foreach ($properties as $keyname) { if (isset($form_state['values'][$keyname])) { @@ -430,15 +430,15 @@ function locale_languages_edit_form_submit($form, &$form_state) { /** * User interface for the language deletion confirmation screen. */ -function locale_languages_delete_form($form, &$form_state, $langcode) { +function locale_languages_delete_form($form, &$form_state, $locale) { // Do not allow deletion of English locale. - if ($langcode == 'en') { + if ($locale == 'en') { drupal_set_message(t('The English language cannot be deleted.')); drupal_goto('admin/config/regional/language'); } - if (language_default('language') == $langcode) { + if (language_default('language') == $locale) { drupal_set_message(t('The default language cannot be deleted.')); drupal_goto('admin/config/regional/language'); } @@ -446,13 +446,13 @@ function locale_languages_delete_form($form, &$form_state, $langcode) { // For other languages, warn user that data loss is ahead. $languages = language_list(); - if (!isset($languages[$langcode])) { + if (!isset($languages[$locale])) { drupal_not_found(); drupal_exit(); } else { - $form['langcode'] = array('#type' => 'value', '#value' => $langcode); - return confirm_form($form, t('Are you sure you want to delete the language %name?', array('%name' => t($languages[$langcode]->name))), 'admin/config/regional/language', t('Deleting a language will remove all interface translations associated with it, and posts in this language will be set to be language neutral. This action cannot be undone.'), t('Delete'), t('Cancel')); + $form['locale'] = array('#type' => 'value', '#value' => $locale); + return confirm_form($form, t('Are you sure you want to delete the language %name?', array('%name' => t($languages[$locale]->name))), 'admin/config/regional/language', t('Deleting a language will remove all interface translations associated with it, and posts in this language will be set to be language neutral. This action cannot be undone.'), t('Delete'), t('Cancel')); } } @@ -461,27 +461,27 @@ function locale_languages_delete_form($form, &$form_state, $langcode) { */ function locale_languages_delete_form_submit($form, &$form_state) { $languages = language_list(); - if (isset($languages[$form_state['values']['langcode']])) { + if (isset($languages[$form_state['values']['locale']])) { // Remove translations first. db_delete('locales_target') - ->condition('language', $form_state['values']['langcode']) + ->condition('language', $form_state['values']['locale']) ->execute(); - cache_clear_all('locale:' . $form_state['values']['langcode'], 'cache'); + cache_clear_all('locale:' . $form_state['values']['locale'], 'cache'); // With no translations, this removes existing JavaScript translations file. - _locale_rebuild_js($form_state['values']['langcode']); + _locale_rebuild_js($form_state['values']['locale']); // Remove the language. db_delete('languages') - ->condition('language', $form_state['values']['langcode']) + ->condition('language', $form_state['values']['locale']) ->execute(); db_update('node') ->fields(array('language' => '')) - ->condition('language', $form_state['values']['langcode']) + ->condition('language', $form_state['values']['locale']) ->execute(); - if ($languages[$form_state['values']['langcode']]->enabled) { + if ($languages[$form_state['values']['locale']]->enabled) { variable_set('language_count', variable_get('language_count', 1) - 1); } module_invoke_all('multilingual_settings_changed'); - $variables = array('%locale' => $languages[$form_state['values']['langcode']]->name); + $variables = array('%locale' => $languages[$form_state['values']['locale']]->name); drupal_set_message(t('The language %locale has been removed.', $variables)); watchdog('locale', 'The language %locale has been removed.', $variables); } @@ -772,10 +772,10 @@ function locale_translate_overview_screen() { // Set up overview table with default values, ensuring common order for values. $rows = array(); - foreach ($languages as $langcode => $language) { - $rows[$langcode] = array('name' => ($langcode == 'en' ? t('English (built-in)') : t($language->name))); + foreach ($languages as $locale => $language) { + $rows[$locale] = array('name' => ($locale == 'en' ? t('English (built-in)') : t($language->name))); foreach ($groups as $group => $name) { - $rows[$langcode][$group] = ($langcode == 'en' ? t('n/a') : '0/' . (isset($groupsums[$group]) ? $groupsums[$group] : 0) . ' (0%)'); + $rows[$locale][$group] = ($locale == 'en' ? t('n/a') : '0/' . (isset($groupsums[$group]) ? $groupsums[$group] : 0) . ' (0%)'); } } @@ -953,7 +953,7 @@ function locale_translate_import_form($form) { '#size' => 50, '#description' => t('A Gettext Portable Object (.po) file.'), ); - $form['import']['langcode'] = array('#type' => 'select', + $form['import']['locale'] = array('#type' => 'select', '#title' => t('Import into'), '#options' => $languages, '#default_value' => $default, @@ -989,16 +989,16 @@ function locale_translate_import_form_submit($form, &$form_state) { // Add language, if not yet supported drupal_static_reset('language_list'); $languages = language_list('language'); - $langcode = $form_state['values']['langcode']; - if (!isset($languages[$langcode])) { + $locale = $form_state['values']['locale']; + if (!isset($languages[$locale])) { include_once DRUPAL_ROOT . '/includes/iso.inc'; $predefined = _locale_get_predefined_list(); - locale_add_language($langcode); - drupal_set_message(t('The language %language has been created.', array('%language' => t($predefined[$langcode][0])))); + locale_add_language($locale); + drupal_set_message(t('The language %language has been created.', array('%language' => t($predefined[$locale][0])))); } // Now import strings into the language - if ($return = _locale_import_po($file, $langcode, $form_state['values']['mode'], $form_state['values']['group']) == FALSE) { + if ($return = _locale_import_po($file, $locale, $form_state['values']['mode'], $form_state['values']['group']) == FALSE) { $variables = array('%filename' => $file->filename); drupal_set_message(t('The translation import of %filename failed.', $variables), 'error'); watchdog('locale', 'The translation import of %filename failed.', $variables, WATCHDOG_ERROR); @@ -1043,7 +1043,7 @@ function locale_translate_export_po_form($form, &$form_state, $names) { $form['export_title'] = array('#type' => 'item', '#title' => t('Export translation'), ); - $form['langcode'] = array('#type' => 'select', + $form['locale'] = array('#type' => 'select', '#title' => t('Language name'), '#options' => $names, '#description' => t('Select the language to export in Gettext Portable Object (.po) format.'), @@ -1085,9 +1085,9 @@ function locale_translate_export_pot_form() { function locale_translate_export_po_form_submit($form, &$form_state) { // If template is required, language code is not given. $language = NULL; - if (isset($form_state['values']['langcode'])) { + if (isset($form_state['values']['locale'])) { $languages = language_list(); - $language = $languages[$form_state['values']['langcode']]; + $language = $languages[$form_state['values']['locale']]; } _locale_export_po($language, _locale_export_po_generate($language, _locale_export_get_strings($language, $form_state['values']['group']))); } @@ -1151,8 +1151,8 @@ function locale_translate_edit_form($form, &$form_state, $lid) { $form['translations'] = array('#tree' => TRUE); // Approximate the number of rows to use in the default textarea. $rows = min(ceil(str_word_count($source->source) / 12), 10); - foreach ($languages as $langcode => $language) { - $form['translations'][$langcode] = array( + foreach ($languages as $locale => $language) { + $form['translations'][$locale] = array( '#type' => 'textarea', '#title' => t($language->name), '#rows' => $rows, @@ -1320,11 +1320,11 @@ function locale_date_format_language_overview_page() { // Get list of languages. $languages = locale_language_list('native'); - foreach ($languages as $langcode => $info) { + foreach ($languages as $locale => $info) { $row = array(); - $row[] = $languages[$langcode]; - $row[] = l(t('edit'), 'admin/config/regional/date-time/locale/' . $langcode . '/edit'); - $row[] = l(t('reset'), 'admin/config/regional/date-time/locale/' . $langcode . '/reset'); + $row[] = $languages[$locale]; + $row[] = l(t('edit'), 'admin/config/regional/date-time/locale/' . $locale . '/edit'); + $row[] = l(t('reset'), 'admin/config/regional/date-time/locale/' . $locale . '/reset'); $rows[] = $row; } @@ -1334,9 +1334,9 @@ function locale_date_format_language_overview_page() { /** * Provide date localization configuration options to users. */ -function locale_date_format_form($form, &$form_state, $langcode) { +function locale_date_format_form($form, &$form_state, $locale) { $languages = locale_language_list('native'); - $language_name = $languages[$langcode]; + $language_name = $languages[$locale]; // Display the current language name. $form['language'] = array( @@ -1345,9 +1345,9 @@ function locale_date_format_form($form, &$form_state, $langcode) { '#markup' => check_plain($language_name), '#weight' => -10, ); - $form['langcode'] = array( + $form['locale'] = array( '#type' => 'value', - '#value' => $langcode, + '#value' => $locale, ); // Get list of date format types. @@ -1364,7 +1364,7 @@ function locale_date_format_form($form, &$form_state, $langcode) { reset($formats); // Get configured formats for each language. - $locale_formats = system_date_format_locale($langcode); + $locale_formats = system_date_format_locale($locale); // Display a form field for each format type. foreach ($types as $type => $type_info) { if (!empty($locale_formats) && in_array($type, array_keys($locale_formats))) { @@ -1398,7 +1398,7 @@ function locale_date_format_form($form, &$form_state, $langcode) { */ function locale_date_format_form_submit($form, &$form_state) { include_once DRUPAL_ROOT . '/includes/locale.inc'; - $langcode = $form_state['values']['langcode']; + $locale = $form_state['values']['locale']; // Get list of date format types. $types = system_get_date_types(); @@ -1407,7 +1407,7 @@ function locale_date_format_form_submit($form, &$form_state) { if ($format == 'custom') { $format = $form_state['values']['date_format_' . $type . '_custom']; } - locale_date_format_save($langcode, $type, $format); + locale_date_format_save($locale, $type, $format); } drupal_set_message(t('Configuration saved.')); $form_state['redirect'] = 'admin/config/regional/date-time/locale'; @@ -1416,14 +1416,14 @@ function locale_date_format_form_submit($form, &$form_state) { /** * Reset locale specific date formats to the global defaults. * - * @param $langcode + * @param $locale * Language code, e.g. 'en'. */ -function locale_date_format_reset_form($form, &$form_state, $langcode) { - $form['langcode'] = array('#type' => 'value', '#value' => $langcode); +function locale_date_format_reset_form($form, &$form_state, $locale) { + $form['locale'] = array('#type' => 'value', '#value' => $locale); $languages = language_list(); return confirm_form($form, - t('Are you sure you want to reset the date formats for %language to the global defaults?', array('%language' => $languages[$langcode]->name)), + t('Are you sure you want to reset the date formats for %language to the global defaults?', array('%language' => $languages[$locale]->name)), 'admin/config/regional/date-time/locale', t('Resetting will remove all localized date formats for this language. This action cannot be undone.'), t('Reset'), t('Cancel')); @@ -1434,7 +1434,7 @@ function locale_date_format_reset_form($form, &$form_state, $langcode) { */ function locale_date_format_reset_form_submit($form, &$form_state) { db_delete('date_format_locale') - ->condition('language', $form_state['values']['langcode']) + ->condition('language', $form_state['values']['locale']) ->execute(); $form_state['redirect'] = 'admin/config/regional/date-time/locale'; } diff --git a/modules/locale/locale.module b/modules/locale/locale.module index 0788461..571d631 100644 --- a/modules/locale/locale.module +++ b/modules/locale/locale.module @@ -233,10 +233,10 @@ function locale_init() { // settings page, where we want to display the site default and not the // localized version. if (strpos($_GET['q'], 'admin/config/regional/date-time/formats') !== 0) { - $languages = array($language->language); + $locales = array($language->language); // Setup appropriate date formats for this locale. - $formats = locale_get_localized_date_format($languages); + $formats = locale_get_localized_date_format($locales); foreach ($formats as $format_type => $format) { $conf[$format_type] = $format; } @@ -282,9 +282,9 @@ function locale_language_selector_form(&$form, &$form_state, $user) { $user_preferred_language = $user->uid ? user_preferred_language($user) : $language; $names = array(); - foreach ($languages as $langcode => $item) { + foreach ($languages as $locale => $item) { $name = t($item->name); - $names[$langcode] = $name . ($item->native != $name ? ' (' . $item->native . ')' : ''); + $names[$locale] = $name . ($item->native != $name ? ' (' . $item->native . ')' : ''); } $form['locale'] = array( '#type' => 'fieldset', @@ -456,10 +456,10 @@ function locale_field_language_alter(&$display_language, $context) { * A reference to an array of language codes keyed by field name. * @param $entity * The entity to be displayed. - * @param $langcode + * @param $locale * The language code $entity has to be displayed in. */ -function locale_field_language_fallback(&$display_language, $entity, $langcode) { +function locale_field_language_fallback(&$display_language, $entity, $locale) { // Lazily init fallback candidates to avoid unnecessary calls. $fallback_candidates = NULL; $field_languages = array(); @@ -467,8 +467,8 @@ function locale_field_language_fallback(&$display_language, $entity, $langcode) foreach ($display_language as $field_name => $field_language) { // If the requested language is defined for the current field use it, // otherwise search for a fallback value among the fallback candidates. - if (isset($entity->{$field_name}[$langcode])) { - $display_language[$field_name] = $langcode; + if (isset($entity->{$field_name}[$locale])) { + $display_language[$field_name] = $locale; } elseif (!empty($entity->{$field_name})) { if (!isset($fallback_candidates)) { @@ -625,10 +625,10 @@ function locale_modules_disabled($modules) { * used on the page. * @param $context * The context of this string. - * @param $langcode + * @param $locale * Language code to use for the lookup. */ -function locale($string = NULL, $context = NULL, $langcode = NULL) { +function locale($string = NULL, $context = NULL, $locale = NULL) { global $language; $locale_t = &drupal_static(__FUNCTION__); @@ -637,47 +637,47 @@ function locale($string = NULL, $context = NULL, $langcode = NULL) { return $locale_t; } - $langcode = isset($langcode) ? $langcode : $language->language; + $locale = isset($locale) ? $locale : $language->language; // Store database cached translations in a static variable. Only build the // cache after $language has been set to avoid an unnecessary cache rebuild. - if (!isset($locale_t[$langcode]) && isset($language)) { - $locale_t[$langcode] = array(); + if (!isset($locale_t[$locale]) && isset($language)) { + $locale_t[$locale] = array(); // Disabling the usage of string caching allows a module to watch for // the exact list of strings used on a page. From a performance // perspective that is a really bad idea, so we have no user // interface for this. Be careful when turning this option off! if (variable_get('locale_cache_strings', 1) == 1) { - if ($cache = cache_get('locale:' . $langcode, 'cache')) { - $locale_t[$langcode] = $cache->data; + if ($cache = cache_get('locale:' . $locale, 'cache')) { + $locale_t[$locale] = $cache->data; } - elseif (lock_acquire('locale_cache_' . $langcode)) { + elseif (lock_acquire('locale_cache_' . $locale)) { // Refresh database stored cache of translations for given language. // We only store short strings used in current version, to improve // performance and consume less memory. - $result = db_query("SELECT s.source, s.context, t.translation, t.language FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language WHERE s.textgroup = 'default' AND s.version = :version AND LENGTH(s.source) < :length", array(':language' => $langcode, ':version' => VERSION, ':length' => variable_get('locale_cache_length', 75))); + $result = db_query("SELECT s.source, s.context, t.translation, t.language FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language WHERE s.textgroup = 'default' AND s.version = :version AND LENGTH(s.source) < :length", array(':language' => $locale, ':version' => VERSION, ':length' => variable_get('locale_cache_length', 75))); foreach ($result as $data) { - $locale_t[$langcode][$data->context][$data->source] = (empty($data->translation) ? TRUE : $data->translation); + $locale_t[$locale][$data->context][$data->source] = (empty($data->translation) ? TRUE : $data->translation); } - cache_set('locale:' . $langcode, $locale_t[$langcode]); - lock_release('locale_cache_' . $langcode); + cache_set('locale:' . $locale, $locale_t[$locale]); + lock_release('locale_cache_' . $locale); } } } // If we have the translation cached, skip checking the database - if (!isset($locale_t[$langcode][$context][$string])) { + if (!isset($locale_t[$locale][$context][$string])) { // We do not have this translation cached, so get it from the DB. $translation = db_query("SELECT s.lid, t.translation, s.version FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language WHERE s.source = :source AND s.context = :context AND s.textgroup = 'default'", array( - ':language' => $langcode, + ':language' => $locale, ':source' => $string, ':context' => (string) $context, ))->fetchObject(); if ($translation) { // We have the source string at least. // Cache translation string or TRUE if no translation exists. - $locale_t[$langcode][$context][$string] = (empty($translation->translation) ? TRUE : $translation->translation); + $locale_t[$locale][$context][$string] = (empty($translation->translation) ? TRUE : $translation->translation); if ($translation->version != VERSION) { // This is the first use of this string under current Drupal version. Save version @@ -701,13 +701,13 @@ function locale($string = NULL, $context = NULL, $langcode = NULL) { 'version' => VERSION, )) ->execute(); - $locale_t[$langcode][$context][$string] = TRUE; + $locale_t[$locale][$context][$string] = TRUE; // Clear locale cache so this string can be added in a later request. cache_clear_all('locale:', 'cache', TRUE); } } - return ($locale_t[$langcode][$context][$string] === TRUE ? $string : $locale_t[$langcode][$context][$string]); + return ($locale_t[$locale][$context][$string] === TRUE ? $string : $locale_t[$locale][$context][$string]); } /** @@ -724,33 +724,33 @@ function locale_reset() { * * @param $count * Number to return plural for. - * @param $langcode + * @param $locale * Optional language code to translate to a language other than * what is used to display the page. */ -function locale_get_plural($count, $langcode = NULL) { +function locale_get_plural($count, $locale = NULL) { global $language; $locale_formula = &drupal_static(__FUNCTION__, array()); $plurals = &drupal_static(__FUNCTION__ . ':plurals', array()); - $langcode = $langcode ? $langcode : $language->language; + $locale = $locale ? $locale : $language->language; - if (!isset($plurals[$langcode][$count])) { + if (!isset($plurals[$locale][$count])) { if (empty($locale_formula)) { - $language_list = language_list(); - $locale_formula[$langcode] = $language_list[$langcode]->formula; + $languages = language_list(); + $locale_formula[$locale] = $languages[$locale]->formula; } - if ($locale_formula[$langcode]) { + if ($locale_formula[$locale]) { $n = $count; - $plurals[$langcode][$count] = @eval('return intval(' . $locale_formula[$langcode] . ');'); - return $plurals[$langcode][$count]; + $plurals[$locale][$count] = @eval('return intval(' . $locale_formula[$locale] . ');'); + return $plurals[$locale][$count]; } else { - $plurals[$langcode][$count] = -1; + $plurals[$locale][$count] = -1; return -1; } } - return $plurals[$langcode][$count]; + return $plurals[$locale][$count]; } diff --git a/modules/locale/locale.test b/modules/locale/locale.test index 42a6dbc..a5fc72d 100644 --- a/modules/locale/locale.test +++ b/modules/locale/locale.test @@ -49,7 +49,7 @@ class LocaleConfigurationTest extends DrupalWebTestCase { // Add predefined language. $edit = array( - 'langcode' => 'fr', + 'locale' => 'fr', ); $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); $this->assertText('fr', t('Language added successfully.')); @@ -57,15 +57,15 @@ class LocaleConfigurationTest extends DrupalWebTestCase { // Add custom language. // Code for the language. - $langcode = 'xx'; + $locale = 'xx'; // The English name for the language. $name = $this->randomName(16); // The native name for the language. $native = $this->randomName(16); // The domain prefix. - $prefix = $langcode; + $prefix = $locale; $edit = array( - 'langcode' => $langcode, + 'locale' => $locale, 'name' => $name, 'native' => $native, 'prefix' => $prefix, @@ -73,7 +73,7 @@ class LocaleConfigurationTest extends DrupalWebTestCase { ); $this->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language')); $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.')); - $this->assertText($langcode, t('Language code found.')); + $this->assertText($locale, t('Language code found.')); $this->assertText($name, t('Name found.')); $this->assertText($native, t('Native found.')); $this->assertText($native, t('Test language added.')); @@ -84,7 +84,7 @@ class LocaleConfigurationTest extends DrupalWebTestCase { $this->assertFieldChecked('edit-site-default-en', t('English is the default language.')); // Change the default language. $edit = array( - 'site_default' => $langcode, + 'site_default' => $locale, ); $this->drupalPost(NULL, $edit, t('Save configuration')); $this->assertNoFieldChecked('edit-site-default-en', t('Default language updated.')); @@ -96,7 +96,7 @@ class LocaleConfigurationTest extends DrupalWebTestCase { $this->assertFieldByXPath('//input[@name="prefix"]', 'en', t('A valid path prefix has been added to the previous default language.')); // Ensure we can't delete the default language. - $this->drupalGet('admin/config/regional/language/delete/' . $langcode); + $this->drupalGet('admin/config/regional/language/delete/' . $locale); $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.')); $this->assertText(t('The default language cannot be deleted.'), t('Failed to delete the default language.')); @@ -122,7 +122,7 @@ class LocaleConfigurationTest extends DrupalWebTestCase { $edit = array( 'name' => $name, ); - $this->drupalPost('admin/config/regional/language/edit/' . $langcode, $edit, t('Save language')); + $this->drupalPost('admin/config/regional/language/edit/' . $locale, $edit, t('Save language')); $this->assertRaw($name, t('The language has been updated.')); $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.')); @@ -131,19 +131,19 @@ class LocaleConfigurationTest extends DrupalWebTestCase { $this->clickLink(t('delete')); $this->assertText(t('Are you sure you want to delete the language'), t('"delete" link is correct.')); // Delete an enabled language. - $this->drupalGet('admin/config/regional/language/delete/' . $langcode); + $this->drupalGet('admin/config/regional/language/delete/' . $locale); // First test the 'cancel' link. $this->clickLink(t('Cancel')); $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.')); $this->assertRaw($name, t('The language was not deleted.')); // Delete the language for real. This a confirm form, we do not need any // fields changed. - $this->drupalPost('admin/config/regional/language/delete/' . $langcode, array(), t('Delete')); + $this->drupalPost('admin/config/regional/language/delete/' . $locale, array(), t('Delete')); // We need raw here because %locale will add HTML. $this->assertRaw(t('The language %locale has been removed.', array('%locale' => $name)), t('The test language has been removed.')); $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.')); // Verify that language is no longer found. - $this->drupalGet('admin/config/regional/language/delete/' . $langcode); + $this->drupalGet('admin/config/regional/language/delete/' . $locale); $this->assertResponse(404, t('Language no longer found.')); // Make sure the "language_count" variable has been updated correctly. drupal_static_reset('language_list'); @@ -206,23 +206,23 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase { // User to translate and delete string. $translate_user = $this->drupalCreateUser(array('translate interface', 'access administration pages')); // Code for the language. - $langcode = 'xx'; + $locale = 'xx'; // The English name for the language. This will be translated. $name = $this->randomName(16); // The native name for the language. $native = $this->randomName(16); // The domain prefix. - $prefix = $langcode; + $prefix = $locale; // This is the language indicator on the translation search screen for // untranslated strings. Copied straight from locale.inc. - $language_indicator = "$langcode "; + $language_indicator = "$locale "; // This will be the translation of $name. $translation = $this->randomName(16); // Add custom language. $this->drupalLogin($admin_user); $edit = array( - 'langcode' => $langcode, + 'locale' => $locale, 'name' => $name, 'native' => $native, 'prefix' => $prefix, @@ -230,10 +230,10 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase { ); $this->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language')); // Add string. - t($name, array(), array('langcode' => $langcode)); + t($name, array(), array('locale' => $locale)); // Reset locale cache. locale_reset(); - $this->assertText($langcode, t('Language code found.')); + $this->assertText($locale, t('Language code found.')); $this->assertText($name, t('Name found.')); $this->assertText($native, t('Native found.')); // No t() here, we do not want to add this string to the database and it's @@ -264,12 +264,12 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase { // No t() here, it's surely not translated yet. $this->assertText($name, t('name found on edit screen.')); $edit = array( - "translations[$langcode]" => $translation, + "translations[$locale]" => $translation, ); $this->drupalPost(NULL, $edit, t('Save translations')); $this->assertText(t('The string has been saved.'), t('The string has been saved.')); $this->assertEqual($this->getUrl(), url('admin/config/regional/translate/translate', array('absolute' => TRUE)), t('Correct page redirection.')); - $this->assertTrue($name != $translation && t($name, array(), array('langcode' => $langcode)) == $translation, t('t() works.')); + $this->assertTrue($name != $translation && t($name, array(), array('locale' => $locale)) == $translation, t('t() works.')); $this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter')); // The indicator should not be here. $this->assertNoRaw($language_indicator, t('String is translated.')); @@ -284,14 +284,14 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase { // Delete the language. $this->drupalLogin($admin_user); - $path = 'admin/config/regional/language/delete/' . $langcode; + $path = 'admin/config/regional/language/delete/' . $locale; // This a confirm form, we do not need any fields changed. $this->drupalPost($path, array(), t('Delete')); // We need raw here because %locale will add HTML. $this->assertRaw(t('The language %locale has been removed.', array('%locale' => $name)), t('The test language has been removed.')); // Reload to remove $name. $this->drupalGet($path); - $this->assertNoText($langcode, t('Language code not found.')); + $this->assertNoText($locale, t('Language code not found.')); $this->assertNoText($name, t('Name not found.')); $this->assertNoText($native, t('Native not found.')); $this->drupalLogout(); @@ -331,17 +331,17 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase { $user = $this->drupalCreateUser(array('translate interface', 'administer languages', 'access administration pages')); $this->drupalLogin($user); - $langcode = 'xx'; + $locale = 'xx'; // The English name for the language. This will be translated. $name = $this->randomName(16); // The native name for the language. $native = $this->randomName(16); // The domain prefix. - $prefix = $langcode; + $prefix = $locale; // Add custom language. $edit = array( - 'langcode' => $langcode, + 'locale' => $locale, 'name' => $name, 'native' => $native, 'prefix' => $prefix, @@ -361,28 +361,28 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase { ->condition('l.textgroup', 'default') ->execute(); $url = 'admin/config/regional/translate/edit/' . $result->fetchObject()->lid; - $edit = array('translations['. $langcode .']' => $this->randomName()); + $edit = array('translations['. $locale .']' => $this->randomName()); $this->drupalPost($url, $edit, t('Save translations')); // Trigger JavaScript translation parsing and building. require_once DRUPAL_ROOT . '/includes/locale.inc'; - _locale_rebuild_js($langcode); + _locale_rebuild_js($locale); // Retrieve the JavaScript translation hash code for the custom language to // check that the translation file has been properly built. $file = db_select('languages', 'l') ->fields('l', array('javascript')) - ->condition('language', $langcode) + ->condition('language', $locale) ->execute() ->fetchObject(); - $js_file = 'public://' . variable_get('locale_js_directory', 'languages') . '/' . $langcode . '_' . $file->javascript . '.js'; + $js_file = 'public://' . variable_get('locale_js_directory', 'languages') . '/' . $locale . '_' . $file->javascript . '.js'; $this->assertTrue($result = file_exists($js_file), t('JavaScript file created: %file', array('%file' => $result ? $js_file : t('not found')))); // Test JavaScript translation rebuilding. file_unmanaged_delete($js_file); $this->assertTrue($result = !file_exists($js_file), t('JavaScript file deleted: %file', array('%file' => $result ? $js_file : t('found')))); cache_clear_all(); - _locale_rebuild_js($langcode); + _locale_rebuild_js($locale); $this->assertTrue($result = file_exists($js_file), t('JavaScript file rebuilt: %file', array('%file' => $result ? $js_file : t('not found')))); } @@ -395,16 +395,16 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase { // User to add language and strings. $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'translate interface')); $this->drupalLogin($admin_user); - $langcode = 'xx'; + $locale = 'xx'; // The English name for the language. This will be translated. $name = $this->randomName(16); // The native name for the language. $native = $this->randomName(16); // The domain prefix. - $prefix = $langcode; + $prefix = $locale; // This is the language indicator on the translation search screen for // untranslated strings. Copied straight from locale.inc. - $language_indicator = "$langcode "; + $language_indicator = "$locale "; // These will be the invalid translations of $name. $key = $this->randomName(16); $bad_translations[$key] = "" . $key; @@ -417,7 +417,7 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase { // Add custom language. $edit = array( - 'langcode' => $langcode, + 'locale' => $locale, 'name' => $name, 'native' => $native, 'prefix' => $prefix, @@ -425,7 +425,7 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase { ); $this->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language')); // Add string. - t($name, array(), array('langcode' => $langcode)); + t($name, array(), array('locale' => $locale)); // Reset locale cache. $search = array( 'string' => $name, @@ -440,7 +440,7 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase { $path = $matches[0]; foreach ($bad_translations as $key => $translation) { $edit = array( - "translations[$langcode]" => $translation, + "translations[$locale]" => $translation, ); $this->drupalPost($path, $edit, t('Save translations')); // Check for a form error on the textarea. @@ -462,23 +462,23 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase { $translate_user = $this->drupalCreateUser(array('translate interface', 'access administration pages')); // Code for the language. - $langcode = 'xx'; + $locale = 'xx'; // The English name for the language. This will be translated. $name = $this->randomName(16); // The native name for the language. $native = $this->randomName(16); // The domain prefix. - $prefix = $langcode; + $prefix = $locale; // This is the language indicator on the translation search screen for // untranslated strings. Copied straight from locale.inc. - $language_indicator = "$langcode "; + $language_indicator = "$locale "; // This will be the translation of $name. $translation = $this->randomName(16); // Add custom language. $this->drupalLogin($admin_user); $edit = array( - 'langcode' => $langcode, + 'locale' => $locale, 'name' => $name, 'native' => $native, 'prefix' => $prefix, @@ -486,7 +486,7 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase { ); $this->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language')); // Add string. - t($name, array(), array('langcode' => $langcode)); + t($name, array(), array('locale' => $locale)); // Reset locale cache. locale_reset(); $this->drupalLogout(); @@ -535,7 +535,7 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase { preg_match('!admin/config/regional/translate/edit/(\d)+!', $this->getUrl(), $matches); $lid = $matches[1]; $edit = array( - "translations[$langcode]" => $translation, + "translations[$locale]" => $translation, ); $this->drupalPost(NULL, $edit, t('Save translations')); @@ -575,7 +575,7 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase { // Ensure translated string does appear if searching on the custom language. $search = array( 'string' => $translation, - 'language' => $langcode, + 'language' => $locale, 'translation' => 'all', 'group' => 'all', ); @@ -635,7 +635,7 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase { function testStandalonePoFile() { // Try importing a .po file. $this->importPoFile($this->getPoFile(), array( - 'langcode' => 'fr', + 'locale' => 'fr', )); // The import should automatically create the corresponding language. @@ -653,7 +653,7 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase { // Try importing a .po file with invalid tags in the default text group. $this->importPoFile($this->getBadPoFile(), array( - 'langcode' => 'fr', + 'locale' => 'fr', )); // The import should have created 1 string and rejected 2. @@ -664,7 +664,7 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase { // Try importing a .po file with invalid tags in a non default text group. $this->importPoFile($this->getBadPoFile(), array( - 'langcode' => 'fr', + 'locale' => 'fr', 'group' => 'custom', )); @@ -675,7 +675,7 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase { // Try importing a .po file which doesn't exist. $name = $this->randomName(16); $this->drupalPost('admin/config/regional/translate/import', array( - 'langcode' => 'fr', + 'locale' => 'fr', 'files[file]' => $name, 'group' => 'custom', ), t('Import')); @@ -686,7 +686,7 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase { // Try importing a .po file with overriding strings, and ensure existing // strings are kept. $this->importPoFile($this->getOverwritePoFile(), array( - 'langcode' => 'fr', + 'locale' => 'fr', 'mode' => 1, // Existing strings are kept, only new strings are added. )); @@ -708,7 +708,7 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase { // Try importing a .po file with overriding strings, and ensure existing // strings are overwritten. $this->importPoFile($this->getOverwritePoFile(), array( - 'langcode' => 'fr', + 'locale' => 'fr', 'mode' => 0, // Strings in the uploaded file replace existing ones, new ones are added. )); @@ -733,17 +733,17 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase { */ function testAutomaticModuleTranslationImportLanguageEnable() { // Code for the language - manually set to match the test translation file. - $langcode = 'xx'; + $locale = 'xx'; // The English name for the language. $name = $this->randomName(16); // The native name for the language. $native = $this->randomName(16); // The domain prefix. - $prefix = $langcode; + $prefix = $locale; // Create a custom language. $edit = array( - 'langcode' => $langcode, + 'locale' => $locale, 'name' => $name, 'native' => $native, 'prefix' => $prefix, @@ -758,7 +758,7 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase { // Ensure strings were successfully imported. $search = array( 'string' => 'lundi', - 'language' => $langcode, + 'language' => $locale, 'translation' => 'translated', 'group' => 'all', ); @@ -772,36 +772,36 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase { function testLanguageContext() { // Try importing a .po file. $this->importPoFile($this->getPoFileWithContext(), array( - 'langcode' => 'hr', + 'locale' => 'hr', )); - $this->assertIdentical(t('May', array(), array('langcode' => 'hr', 'context' => 'Long month name')), 'Svibanj', t('Long month name context is working.')); - $this->assertIdentical(t('May', array(), array('langcode' => 'hr')), 'Svi.', t('Default context is working.')); + $this->assertIdentical(t('May', array(), array('locale' => 'hr', 'context' => 'Long month name')), 'Svibanj', t('Long month name context is working.')); + $this->assertIdentical(t('May', array(), array('locale' => 'hr')), 'Svi.', t('Default context is working.')); } /** * Test empty msgstr at end of .po file see #611786. */ function testEmptyMsgstr() { - $langcode = 'hu'; + $locale = 'hu'; // Try importing a .po file. $this->importPoFile($this->getPoFileWithMsgstr(), array( - 'langcode' => $langcode, + 'locale' => $locale, )); $this->assertRaw(t('The translation was successfully imported. There are %number newly created translated strings, %update strings were updated and %delete strings were removed.', array('%number' => 1, '%update' => 0, '%delete' => 0)), t('The translation file was successfully imported.')); - $this->assertIdentical(t('Operations', array(), array('langcode' => $langcode)), 'Műveletek', t('String imported and translated.')); + $this->assertIdentical(t('Operations', array(), array('locale' => $locale)), 'Műveletek', t('String imported and translated.')); // Try importing a .po file. $this->importPoFile($this->getPoFileWithEmptyMsgstr(), array( - 'langcode' => $langcode, + 'locale' => $locale, 'mode' => 0, )); $this->assertRaw(t('The translation was successfully imported. There are %number newly created translated strings, %update strings were updated and %delete strings were removed.', array('%number' => 0, '%update' => 0, '%delete' => 1)), t('The translation file was successfully imported.')); // This is the language indicator on the translation search screen for // untranslated strings. Copied straight from locale.inc. - $language_indicator = "$langcode "; + $language_indicator = "$locale "; $str = "Operations"; $search = array( 'string' => $str, @@ -1019,14 +1019,14 @@ class LocaleExportFunctionalTest extends DrupalWebTestCase { $name = tempnam('temporary://', "po_") . '.po'; file_put_contents($name, $this->getPoFile()); $this->drupalPost('admin/config/regional/translate/import', array( - 'langcode' => 'fr', + 'locale' => 'fr', 'files[file]' => $name, ), t('Import')); drupal_unlink($name); // Get the French translations. $this->drupalPost('admin/config/regional/translate/export', array( - 'langcode' => 'fr', + 'locale' => 'fr', ), t('Export')); // Ensure we have a translation file. @@ -1277,7 +1277,7 @@ class LocaleLanguageSwitchingFunctionalTest extends DrupalWebTestCase { // Add language. $edit = array( - 'langcode' => 'fr', + 'locale' => 'fr', ); $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); @@ -1351,7 +1351,7 @@ class LocaleUserLanguageFunctionalTest extends DrupalWebTestCase { // Add custom language. $this->drupalLogin($admin_user); // Code for the language. - $langcode = 'xx'; + $locale = 'xx'; // The English name for the language. $name = $this->randomName(16); // The native name for the language. @@ -1359,7 +1359,7 @@ class LocaleUserLanguageFunctionalTest extends DrupalWebTestCase { // The domain prefix. $prefix = 'xx'; $edit = array( - 'langcode' => $langcode, + 'locale' => $locale, 'name' => $name, 'native' => $native, 'prefix' => $prefix, @@ -1369,15 +1369,15 @@ class LocaleUserLanguageFunctionalTest extends DrupalWebTestCase { // Add custom language and disable it. // Code for the language. - $langcode_disabled = 'xx-yy'; + $locale_disabled = 'xx-yy'; // The English name for the language. This will be translated. $name_disabled = $this->randomName(16); // The native name for the language. $native_disabled = $this->randomName(16); // The domain prefix. - $prefix_disabled = $langcode_disabled; + $prefix_disabled = $locale_disabled; $edit = array( - 'langcode' => $langcode_disabled, + 'locale' => $locale_disabled, 'name' => $name_disabled, 'native' => $native_disabled, 'prefix' => $prefix_disabled, @@ -1386,7 +1386,7 @@ class LocaleUserLanguageFunctionalTest extends DrupalWebTestCase { $this->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language')); // Disable the language. $edit = array( - 'enabled[' . $langcode_disabled . ']' => FALSE, + 'enabled[' . $locale_disabled . ']' => FALSE, ); $this->drupalPost('admin/config/regional/language', $edit, t('Save configuration')); $this->drupalLogout(); @@ -1403,13 +1403,13 @@ class LocaleUserLanguageFunctionalTest extends DrupalWebTestCase { $this->assertNoText($name_disabled, t('Disabled language not present on form.')); // Switch to our custom language. $edit = array( - 'language' => $langcode, + 'language' => $locale, ); $this->drupalPost($path, $edit, t('Save')); // Ensure form was submitted successfully. $this->assertText(t('The changes have been saved.'), t('Changes were saved.')); // Check if language was changed. - $elements = $this->xpath('//input[@id=:id]', array(':id' => 'edit-language-' . $langcode)); + $elements = $this->xpath('//input[@id=:id]', array(':id' => 'edit-language-' . $locale)); $this->assertTrue(isset($elements[0]) && !empty($elements[0]['checked']), t('Default language successfully updated.')); $this->drupalLogout(); @@ -1443,12 +1443,12 @@ class LocaleUserCreationTest extends DrupalWebTestCase { $this->drupalLogin($admin_user); // Add predefined language. - $langcode = 'fr'; + $locale = 'fr'; $edit = array( - 'langcode' => 'fr', + 'locale' => 'fr', ); $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); - $this->assertText($langcode, t('Language added successfully.')); + $this->assertText($locale, t('Language added successfully.')); $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.')); // Set language negotiation. @@ -1460,8 +1460,8 @@ class LocaleUserCreationTest extends DrupalWebTestCase { // Check if the language selector is available on admin/people/create and // set to the currently active language. - $this->drupalGet($langcode . '/admin/people/create'); - $this->assertFieldChecked("edit-language-$langcode", t('Global language set in the language selector.')); + $this->drupalGet($locale . '/admin/people/create'); + $this->assertFieldChecked("edit-language-$locale", t('Global language set in the language selector.')); // Create a user with the admin/people/create form and check if the correct // language is set. @@ -1473,15 +1473,15 @@ class LocaleUserCreationTest extends DrupalWebTestCase { 'pass[pass2]' => $username, ); - $this->drupalPost($langcode . '/admin/people/create', $edit, t('Create new account')); + $this->drupalPost($locale . '/admin/people/create', $edit, t('Create new account')); $user = user_load_by_name($username); - $this->assertEqual($user->language, $langcode, t('New user has correct language set.')); + $this->assertEqual($user->language, $locale, t('New user has correct language set.')); // Register a new user and check if the language selector is hidden. $this->drupalLogout(); - $this->drupalGet($langcode . '/user/register'); + $this->drupalGet($locale . '/user/register'); $this->assertNoFieldByName('language[fr]', t('Language selector is not accessible.')); $username = $this->randomName(10); @@ -1490,18 +1490,18 @@ class LocaleUserCreationTest extends DrupalWebTestCase { 'mail' => $this->randomName(4) . '@example.com', ); - $this->drupalPost($langcode . '/user/register', $edit, t('Create new account')); + $this->drupalPost($locale . '/user/register', $edit, t('Create new account')); $user = user_load_by_name($username); - $this->assertEqual($user->language, $langcode, t('New user has correct language set.')); + $this->assertEqual($user->language, $locale, t('New user has correct language set.')); // Test if the admin can use the language selector and if the // correct language is was saved. - $user_edit = $langcode . '/user/' . $user->uid . '/edit'; + $user_edit = $locale . '/user/' . $user->uid . '/edit'; $this->drupalLogin($admin_user); $this->drupalGet($user_edit); - $this->assertFieldChecked("edit-language-$langcode", t('Language selector is accessible and correct language is selected.')); + $this->assertFieldChecked("edit-language-$locale", t('Language selector is accessible and correct language is selected.')); // Set pass_raw so we can login the new user. $user->pass_raw = $this->randomName(10); @@ -1514,7 +1514,7 @@ class LocaleUserCreationTest extends DrupalWebTestCase { $this->drupalLogin($user); $this->drupalGet($user_edit); - $this->assertFieldChecked("edit-language-$langcode", t('Language selector is accessible and correct language is selected.')); + $this->assertFieldChecked("edit-language-$locale", t('Language selector is accessible and correct language is selected.')); } } @@ -1546,15 +1546,15 @@ class LocalePathFunctionalTest extends DrupalWebTestCase { // Add custom language. $this->drupalLogin($admin_user); // Code for the language. - $langcode = 'xx'; + $locale = 'xx'; // The English name for the language. $name = $this->randomName(16); // The native name for the language. $native = $this->randomName(16); // The domain prefix. - $prefix = $langcode; + $prefix = $locale; $edit = array( - 'langcode' => $langcode, + 'locale' => $locale, 'name' => $name, 'native' => $native, 'prefix' => $prefix, @@ -1590,7 +1590,7 @@ class LocalePathFunctionalTest extends DrupalWebTestCase { $edit = array( 'source' => 'node/' . $node->nid, 'alias' => $custom_language_path, - 'language' => $langcode, + 'language' => $locale, ); $this->drupalPost($path, $edit, t('Save')); @@ -1688,15 +1688,15 @@ class LocaleContentFunctionalTest extends DrupalWebTestCase { // Add custom language. $this->drupalLogin($admin_user); // Code for the language. - $langcode = 'xx'; + $locale = 'xx'; // The English name for the language. $name = $this->randomName(16); // The native name for the language. $native = $this->randomName(16); // The domain prefix. - $prefix = $langcode; + $prefix = $locale; $edit = array( - 'langcode' => $langcode, + 'locale' => $locale, 'name' => $name, 'native' => $native, 'prefix' => $prefix, @@ -1706,15 +1706,15 @@ class LocaleContentFunctionalTest extends DrupalWebTestCase { // Add disabled custom language. // Code for the language. - $langcode_disabled = 'xx-yy'; + $locale_disabled = 'xx-yy'; // The English name for the language. $name_disabled = $this->randomName(16); // The native name for the language. $native_disabled = $this->randomName(16); // The domain prefix. - $prefix_disabled = $langcode_disabled; + $prefix_disabled = $locale_disabled; $edit = array( - 'langcode' => $langcode_disabled, + 'locale' => $locale_disabled, 'name' => $name_disabled, 'native' => $native_disabled, 'prefix' => $prefix_disabled, @@ -1724,7 +1724,7 @@ class LocaleContentFunctionalTest extends DrupalWebTestCase { // Disable second custom language. $path = 'admin/config/regional/language'; $edit = array( - 'enabled[' . $langcode_disabled . ']' => FALSE, + 'enabled[' . $locale_disabled . ']' => FALSE, ); $this->drupalPost($path, $edit, t('Save configuration')); @@ -1759,14 +1759,14 @@ class LocaleContentFunctionalTest extends DrupalWebTestCase { $edit = array( 'type' => 'page', 'title' => $node_title, - 'body' => array($langcode => array(array('value' => $node_body))), - 'language' => $langcode, + 'body' => array($locale => array(array('value' => $node_body))), + 'language' => $locale, ); $node = $this->drupalCreateNode($edit); // Edit the content and ensure correct language is selected. $path = 'node/' . $node->nid . '/edit'; $this->drupalGet($path); - $this->assertRaw('', t('Correct language selected.')); + $this->assertRaw('', t('Correct language selected.')); // Ensure we can change the node language. $edit = array( 'language' => 'en', @@ -2044,12 +2044,12 @@ class LocaleUrlRewritingTest extends DrupalWebTestCase { // Install French language. $edit = array(); - $edit['langcode'] = 'fr'; + $edit['locale'] = 'fr'; $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); // Install Italian language. $edit = array(); - $edit['langcode'] = 'it'; + $edit['locale'] = 'it'; $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); // Disable Italian language. @@ -2144,10 +2144,10 @@ class LocaleMultilingualFieldsFunctionalTest extends DrupalWebTestCase { */ function testMultilingualNodeForm() { // Create "Basic page" content. - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $title_key = "title"; $title_value = $this->randomName(8); - $body_key = "body[$langcode][0][value]"; + $body_key = "body[$locale][0][value]"; $body_value = $this->randomName(16); // Create node to edit. @@ -2193,10 +2193,10 @@ class LocaleMultilingualFieldsFunctionalTest extends DrupalWebTestCase { */ function testMultilingualDisplaySettings() { // Create "Basic page" content. - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $title_key = "title"; $title_value = $this->randomName(8); - $body_key = "body[$langcode][0][value]"; + $body_key = "body[$locale][0][value]"; $body_value = $this->randomName(16); // Create node to edit. @@ -2238,7 +2238,7 @@ class LocaleCommentLanguageFunctionalTest extends DrupalWebTestCase { $this->drupalLogin($admin_user); // Add language. - $edit = array('langcode' => 'fr'); + $edit = array('locale' => 'fr'); $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); // Set "Article" content type to use multilingual support. @@ -2277,7 +2277,7 @@ class LocaleCommentLanguageFunctionalTest extends DrupalWebTestCase { // is the user language preference. This way we can ensure that node // language and interface language do not influence comment language, as // only content language has to. - foreach (language_list() as $node_langcode => $node_language) { + foreach (language_list() as $node_locale => $node_language) { $language_none = LANGUAGE_NONE; // Create "Article" content. @@ -2285,13 +2285,13 @@ class LocaleCommentLanguageFunctionalTest extends DrupalWebTestCase { $edit = array( "title" => $title, "body[$language_none][0][value]" => $this->randomName(), - "language" => $node_langcode, + "language" => $node_locale, ); $this->drupalPost("node/add/article", $edit, t('Save')); $node = $this->drupalGetNodeByTitle($title); - foreach (language_list() as $langcode => $language) { - // Post a comment with content language $langcode. + foreach (language_list() as $locale => $language) { + // Post a comment with content language $locale. $prefix = empty($language->prefix) ? '' : $language->prefix . '/'; $edit = array("comment_body[$language_none][0][value]" => $this->randomName()); $this->drupalPost("{$prefix}node/{$node->nid}", $edit, t('Save')); @@ -2303,8 +2303,8 @@ class LocaleCommentLanguageFunctionalTest extends DrupalWebTestCase { ->orderBy('cid', 'DESC') ->execute() ->fetchObject(); - $args = array('%node_language' => $node_langcode, '%comment_language' => $comment->language, '%langcode' => $langcode); - $this->assertEqual($comment->language, $langcode, t('The comment posted with content language %langcode and belonging to the node with language %node_language has language %comment_language', $args)); + $args = array('%node_language' => $node_locale, '%comment_language' => $comment->language, '%locale' => $locale); + $this->assertEqual($comment->language, $locale, t('The comment posted with content language %locale and belonging to the node with language %node_language has language %comment_language', $args)); } } } @@ -2336,7 +2336,7 @@ class LocaleDateFormatsFunctionalTest extends DrupalWebTestCase { function testLocalizeDateFormats() { // Add language. $edit = array( - 'langcode' => 'fr', + 'locale' => 'fr', ); $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); @@ -2396,7 +2396,7 @@ class LocaleLanguageNegotiationInfoFunctionalTest extends DrupalWebTestCase { require_once DRUPAL_ROOT .'/includes/language.inc'; $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'view the administration theme')); $this->drupalLogin($admin_user); - $this->drupalPost('admin/config/regional/language/add', array('langcode' => 'it'), t('Add language')); + $this->drupalPost('admin/config/regional/language/add', array('locale' => 'it'), t('Add language')); } /** @@ -2457,9 +2457,9 @@ class LocaleLanguageNegotiationInfoFunctionalTest extends DrupalWebTestCase { $this->drupalGet(''); $last = variable_get('locale_test_language_negotiation_last', array()); foreach (language_types() as $type) { - $langcode = $last[$type]; + $locale = $last[$type]; $value = $type == LANGUAGE_TYPE_CONTENT || strpos($type, 'test') !== FALSE ? 'it' : 'en'; - $this->assertEqual($langcode, $value, t('The negotiated language for %type is %language', array('%type' => $type, '%language' => $langcode))); + $this->assertEqual($locale, $value, t('The negotiated language for %type is %language', array('%type' => $type, '%language' => $locale))); } // Disable locale_test and check that everything is set back to the original diff --git a/modules/node/node.admin.inc b/modules/node/node.admin.inc index a6ea1b5..3af6d3d 100644 --- a/modules/node/node.admin.inc +++ b/modules/node/node.admin.inc @@ -456,7 +456,7 @@ function node_admin_nodes() { $options[$node->nid]['language'] = $node->language == LANGUAGE_NONE ? t('Language neutral') : t($languages[$node->language]->name); } else { - $options[$node->nid]['language'] = t('Undefined language (@langcode)', array('@langcode' => $node->language)); + $options[$node->nid]['language'] = t('Undefined language (@locale)', array('@locale' => $node->language)); } } // Build a list of all the accessible operations for the current node. diff --git a/modules/node/node.api.php b/modules/node/node.api.php index 1801b67..adc9bbc 100644 --- a/modules/node/node.api.php +++ b/modules/node/node.api.php @@ -800,14 +800,14 @@ function hook_node_submit($node, $form, &$form_state) { * The node that is being assembled for rendering. * @param $view_mode * The $view_mode parameter from node_view(). - * @param $langcode + * @param $locale * The language code used for rendering. * * @see hook_entity_view() * * @ingroup node_api_hooks */ -function hook_node_view($node, $view_mode, $langcode) { +function hook_node_view($node, $view_mode, $locale) { $node->content['my_additional_field'] = array( '#markup' => $additional_field, '#weight' => 10, diff --git a/modules/node/node.module b/modules/node/node.module index 958972d..9e3de6a 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -1270,20 +1270,20 @@ function node_revision_delete($revision_id) { * A node object. * @param $view_mode * View mode, e.g. 'full', 'teaser'... - * @param $langcode + * @param $locale * (optional) A language code to use for rendering. Defaults to the global * content language of the current request. * * @return * An array as expected by drupal_render(). */ -function node_view($node, $view_mode = 'full', $langcode = NULL) { - if (!isset($langcode)) { - $langcode = $GLOBALS['language_content']->language; +function node_view($node, $view_mode = 'full', $locale = NULL) { + if (!isset($locale)) { + $locale = $GLOBALS['language_content']->language; } // Populate $node->content with a render() array. - node_build_content($node, $view_mode, $langcode); + node_build_content($node, $view_mode, $locale); $build = $node->content; // We don't need duplicate rendering info in node->content. @@ -1293,7 +1293,7 @@ function node_view($node, $view_mode = 'full', $langcode = NULL) { '#theme' => 'node', '#node' => $node, '#view_mode' => $view_mode, - '#language' => $langcode, + '#language' => $locale, ); // Add contextual links for this node, except when the node is already being @@ -1335,13 +1335,13 @@ function node_view($node, $view_mode = 'full', $langcode = NULL) { * A node object. * @param $view_mode * View mode, e.g. 'full', 'teaser'... - * @param $langcode + * @param $locale * (optional) A language code to use for rendering. Defaults to the global * content language of the current request. */ -function node_build_content($node, $view_mode = 'full', $langcode = NULL) { - if (!isset($langcode)) { - $langcode = $GLOBALS['language_content']->language; +function node_build_content($node, $view_mode = 'full', $locale = NULL) { + if (!isset($locale)) { + $locale = $GLOBALS['language_content']->language; } // Remove previously built content, if exists. @@ -1350,16 +1350,16 @@ function node_build_content($node, $view_mode = 'full', $langcode = NULL) { // The 'view' hook can be implemented to overwrite the default function // to display nodes. if (node_hook($node, 'view')) { - $node = node_invoke($node, 'view', $view_mode, $langcode); + $node = node_invoke($node, 'view', $view_mode, $locale); } // Build fields content. // In case of a multiple view, node_view_multiple() already ran the // 'prepare_view' step. An internal flag prevents the operation from running // twice. - field_attach_prepare_view('node', array($node->nid => $node), $view_mode, $langcode); - entity_prepare_view('node', array($node->nid => $node), $langcode); - $node->content += field_attach_view('node', $node, $view_mode, $langcode); + field_attach_prepare_view('node', array($node->nid => $node), $view_mode, $locale); + entity_prepare_view('node', array($node->nid => $node), $locale); + $node->content += field_attach_view('node', $node, $view_mode, $locale); // Always display a read more link on teasers because we have no way // to know when a teaser view is different than a full view. @@ -1385,8 +1385,8 @@ function node_build_content($node, $view_mode = 'full', $langcode = NULL) { ); // Allow modules to make their own additions to the node. - module_invoke_all('node_view', $node, $view_mode, $langcode); - module_invoke_all('entity_view', $node, 'node', $view_mode, $langcode); + module_invoke_all('node_view', $node, $view_mode, $locale); + module_invoke_all('entity_view', $node, 'node', $view_mode, $locale); } /** @@ -2511,19 +2511,19 @@ function node_feed($nids = FALSE, $channel = array()) { * View mode, e.g. 'full', 'teaser'... * @param $weight * An integer representing the weight of the first node in the list. - * @param $langcode + * @param $locale * (optional) A language code to use for rendering. Defaults to the global * content language of the current request. * * @return * An array in the format expected by drupal_render(). */ -function node_view_multiple($nodes, $view_mode = 'teaser', $weight = 0, $langcode = NULL) { - field_attach_prepare_view('node', $nodes, $view_mode, $langcode); - entity_prepare_view('node', $nodes, $langcode); +function node_view_multiple($nodes, $view_mode = 'teaser', $weight = 0, $locale = NULL) { + field_attach_prepare_view('node', $nodes, $view_mode, $locale); + entity_prepare_view('node', $nodes, $locale); $build = array(); foreach ($nodes as $node) { - $build['nodes'][$node->nid] = node_view($node, $view_mode, $langcode); + $build['nodes'][$node->nid] = node_view($node, $view_mode, $locale); $build['nodes'][$node->nid]['#weight'] = $weight; $weight++; } diff --git a/modules/node/node.test b/modules/node/node.test index 56a2d34..dca7049 100644 --- a/modules/node/node.test +++ b/modules/node/node.test @@ -287,9 +287,9 @@ class PageEditTestCase extends DrupalWebTestCase { function testPageEdit() { $this->drupalLogin($this->web_user); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $title_key = "title"; - $body_key = "body[$langcode][0][value]"; + $body_key = "body[$locale][0][value]"; // Create node to edit. $edit = array(); $edit[$title_key] = $this->randomName(8); @@ -355,8 +355,8 @@ class PageEditTestCase extends DrupalWebTestCase { $this->drupalLogin($this->admin_user); // Create node to edit. - $langcode = LANGUAGE_NONE; - $body_key = "body[$langcode][0][value]"; + $locale = LANGUAGE_NONE; + $body_key = "body[$locale][0][value]"; $edit = array(); $edit['title'] = $this->randomName(8); $edit[$body_key] = $this->randomName(16); @@ -414,9 +414,9 @@ class PagePreviewTestCase extends DrupalWebTestCase { * Check the node preview functionality. */ function testPagePreview() { - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $title_key = "title"; - $body_key = "body[$langcode][0][value]"; + $body_key = "body[$locale][0][value]"; // Fill in node creation form and preview node. $edit = array(); @@ -438,9 +438,9 @@ class PagePreviewTestCase extends DrupalWebTestCase { * Check the node preview functionality, when using revisions. */ function testPagePreviewWithRevisions() { - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $title_key = "title"; - $body_key = "body[$langcode][0][value]"; + $body_key = "body[$locale][0][value]"; // Force revision on "Basic page" content. variable_set('node_options_page', array('status', 'revision')); @@ -488,9 +488,9 @@ class NodeCreationTestCase extends DrupalWebTestCase { function testNodeCreation() { // Create a node. $edit = array(); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $edit["title"] = $this->randomName(8); - $edit["body[$langcode][0][value]"] = $this->randomName(16); + $edit["body[$locale][0][value]"] = $this->randomName(16); $this->drupalPost('node/add/page', $edit, t('Save')); // Check that the Basic page has been created. @@ -719,9 +719,9 @@ class NodePostSettingsTestCase extends DrupalWebTestCase { // Create a node. $edit = array(); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $edit["title"] = $this->randomName(8); - $edit["body[$langcode][0][value]"] = $this->randomName(16); + $edit["body[$locale][0][value]"] = $this->randomName(16); $this->drupalPost('node/add/page', $edit, t('Save')); // Check that the post information is displayed. @@ -742,9 +742,9 @@ class NodePostSettingsTestCase extends DrupalWebTestCase { // Create a node. $edit = array(); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $edit["title"] = $this->randomName(8); - $edit["body[$langcode][0][value]"] = $this->randomName(16); + $edit["body[$locale][0][value]"] = $this->randomName(16); $this->drupalPost('node/add/page', $edit, t('Save')); // Check that the post information is displayed. diff --git a/modules/path/path.test b/modules/path/path.test index 4112e5f..74b9f36 100644 --- a/modules/path/path.test +++ b/modules/path/path.test @@ -246,7 +246,7 @@ class PathLanguageTestCase extends DrupalWebTestCase { // Enable French language. $edit = array(); - $edit['langcode'] = 'fr'; + $edit['locale'] = 'fr'; $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); @@ -386,7 +386,7 @@ class PathLanguageUITestCase extends DrupalWebTestCase { // Enable French language. $edit = array(); - $edit['langcode'] = 'fr'; + $edit['locale'] = 'fr'; $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); @@ -463,7 +463,7 @@ class PathMonolingualTestCase extends DrupalWebTestCase { // Enable French language. $edit = array(); - $edit['langcode'] = 'fr'; + $edit['locale'] = 'fr'; $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); // Make French the default language. diff --git a/modules/php/php.test b/modules/php/php.test index 8ead2ac..6b36a68 100644 --- a/modules/php/php.test +++ b/modules/php/php.test @@ -77,8 +77,8 @@ class PHPFilterTestCase extends PHPTestCase { // Change filter to PHP filter and see that PHP code is evaluated. $edit = array(); - $langcode = LANGUAGE_NONE; - $edit["body[$langcode][0][format]"] = $this->php_code_format->format; + $locale = LANGUAGE_NONE; + $edit["body[$locale][0][format]"] = $this->php_code_format->format; $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save')); $this->assertRaw(t('Basic page %title has been updated.', array('%title' => $node->title)), t('PHP code filter turned on.')); diff --git a/modules/rdf/rdf.test b/modules/rdf/rdf.test index 9f786ab..deb9167 100644 --- a/modules/rdf/rdf.test +++ b/modules/rdf/rdf.test @@ -123,7 +123,7 @@ class RdfRdfaMarkupTestCase extends DrupalWebTestCase { $admin_user = $this->drupalCreateUser(array('edit own article content', 'revert revisions', 'administer content types')); $this->drupalLogin($admin_user); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $bundle_name = "article"; $field_name = 'file_test'; @@ -160,8 +160,8 @@ class RdfRdfaMarkupTestCase extends DrupalWebTestCase { // Create an array for drupalPost with the field names as the keys and // the uris for the test files as the values. - $edit = array("files[" . $field_name . "_" . $langcode . "_0]" => drupal_realpath($file->uri), - "files[" . $image_field . "_" . $langcode . "_0]" => drupal_realpath($image->uri)); + $edit = array("files[" . $field_name . "_" . $locale . "_0]" => drupal_realpath($file->uri), + "files[" . $image_field . "_" . $locale . "_0]" => drupal_realpath($image->uri)); // Create node and save, then edit node to upload files. $node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1)); diff --git a/modules/search/search.test b/modules/search/search.test index 4d37133..63060b7 100644 --- a/modules/search/search.test +++ b/modules/search/search.test @@ -1417,8 +1417,8 @@ class SearchConfigSettingsForm extends DrupalWebTestCase { $this->search_node = $node; // Link the node to itself to test that it's only indexed once. The content // also needs the word "pizza" so we can use it as the search keyword. - $langcode = LANGUAGE_NONE; - $body_key = "body[$langcode][0][value]"; + $locale = LANGUAGE_NONE; + $body_key = "body[$locale][0][value]"; $edit[$body_key] = l($node->title, 'node/' . $node->nid) . ' pizza sandwich'; $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save')); @@ -1912,7 +1912,7 @@ class SearchLanguageTestCase extends DrupalWebTestCase { $this->assertNoText(t('Languages'), t('No languages to choose from.')); // Add predefined language. - $edit = array('langcode' => 'fr'); + $edit = array('locale' => 'fr'); $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); $this->assertText('fr', t('Language added successfully.')); diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test index 177e457..c36f947 100644 --- a/modules/simpletest/tests/common.test +++ b/modules/simpletest/tests/common.test @@ -2144,7 +2144,7 @@ class DrupalSystemListingTestCase extends DrupalWebTestCase { class FormatDateUnitTest extends DrupalWebTestCase { /** - * Arbitrary langcode for a custom language. + * Arbitrary locale for a custom language. */ const LANGCODE = 'xx'; @@ -2213,7 +2213,7 @@ class FormatDateUnitTest extends DrupalWebTestCase { $admin_user = $this->drupalCreateUser(array('administer languages')); $this->drupalLogin($admin_user); $edit = array( - 'langcode' => self::LANGCODE, + 'locale' => self::LANGCODE, 'name' => self::LANGCODE, 'native' => self::LANGCODE, 'direction' => LANGUAGE_LTR, diff --git a/modules/simpletest/tests/filter_test.module b/modules/simpletest/tests/filter_test.module index 2cebc70..8b4ccb6 100644 --- a/modules/simpletest/tests/filter_test.module +++ b/modules/simpletest/tests/filter_test.module @@ -48,11 +48,11 @@ function filter_test_filter_info() { * * Replaces all text with filter and text format information. */ -function filter_test_replace($text, $filter, $format, $langcode, $cache, $cache_id) { +function filter_test_replace($text, $filter, $format, $locale, $cache, $cache_id) { $text = array(); $text[] = 'Filter: ' . $filter->title . ' (' . $filter->name . ')'; $text[] = 'Format: ' . $format->name . ' (' . $format->format . ')'; - $text[] = 'Language: ' . $langcode; + $text[] = 'Language: ' . $locale; $text[] = 'Cache: ' . ($cache ? 'Enabled' : 'Disabled'); if ($cache_id) { $text[] = 'Cache ID: ' . $cache_id; diff --git a/modules/simpletest/tests/menu.test b/modules/simpletest/tests/menu.test index bb01265..0e75f45 100644 --- a/modules/simpletest/tests/menu.test +++ b/modules/simpletest/tests/menu.test @@ -930,7 +930,7 @@ class MenuBreadcrumbTestCase extends DrupalWebTestCase { $admin = $home + array('admin' => t('Administration')); $config = $admin + array('admin/config' => t('Configuration')); $type = 'article'; - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; // Verify breadcrumbs for default local tasks. $expected = array( @@ -1169,7 +1169,7 @@ class MenuBreadcrumbTestCase extends DrupalWebTestCase { 'Breadcrumbs' => array(), ); $edit = array( - "field_tags[$langcode]" => implode(',', array_keys($tags)), + "field_tags[$locale]" => implode(',', array_keys($tags)), ); $this->drupalPost("node/{$parent->nid}/edit", $edit, t('Save')); diff --git a/modules/system/system.api.php b/modules/system/system.api.php index d21af6a..f771f17 100644 --- a/modules/system/system.api.php +++ b/modules/system/system.api.php @@ -392,7 +392,7 @@ function hook_entity_query_alter($query) { * The type of entity being rendered (i.e. node, user, comment). * @param $view_mode * The view mode the entity is rendered in. - * @param $langcode + * @param $locale * The language code used for rendering. * * The module may add elements to $entity->content prior to rendering. The @@ -404,7 +404,7 @@ function hook_entity_query_alter($query) { * @see hook_node_view() * @see hook_user_view() */ -function hook_entity_view($entity, $type, $view_mode, $langcode) { +function hook_entity_view($entity, $type, $view_mode, $locale) { $entity->content['my_additional_field'] = array( '#markup' => $additional_field, '#weight' => 10, @@ -502,10 +502,10 @@ function hook_admin_paths_alter(&$paths) { * The entities keyed by entity ID. * @param $type * The type of entities being loaded (i.e. node, user, comment). - * @param $langcode + * @param $locale * The language to display the entity in. */ -function hook_entity_prepare_view($entities, $type, $langcode) { +function hook_entity_prepare_view($entities, $type, $locale) { // Load a specific node into the user object for later theming. if ($type == 'user') { $nodes = mymodule_get_user_nodes(array_keys($entities)); diff --git a/modules/system/system.module b/modules/system/system.module index 7d423ab..3251f11 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -3592,7 +3592,7 @@ function system_date_formats_rebuild() { /** * Gets the appropriate date format string for a date type and locale. * - * @param $langcode + * @param $locale * (optional) Language code for the current locale. This can be a 2 character * language code like 'en' and 'fr' or a 5 character language code like * 'en-gb' and 'en-us'. @@ -3600,12 +3600,12 @@ function system_date_formats_rebuild() { * (optional) The date type name. * * @return - * If $type and $langcode are specified, returns the corresponding date format - * string. If only $langcode is specified, returns an array of all date + * If $type and $locale are specified, returns the corresponding date format + * string. If only $locale is specified, returns an array of all date * format strings for that locale, keyed by the date type. If neither is * specified, or if no matching formats are found, returns FALSE. */ -function system_date_format_locale($langcode = NULL, $type = NULL) { +function system_date_format_locale($locale = NULL, $type = NULL) { $formats = &drupal_static(__FUNCTION__); if (empty($formats)) { @@ -3619,11 +3619,11 @@ function system_date_format_locale($langcode = NULL, $type = NULL) { } } - if ($type && $langcode && !empty($formats[$langcode][$type])) { - return $formats[$langcode][$type]; + if ($type && $locale && !empty($formats[$locale][$type])) { + return $formats[$locale][$type]; } - elseif ($langcode && !empty($formats[$langcode])) { - return $formats[$langcode]; + elseif ($locale && !empty($formats[$locale])) { + return $formats[$locale]; } return FALSE; @@ -3862,12 +3862,12 @@ function system_date_format_save($date_format, $dfid = 0) { // Check if the suggested language codes are configured and enabled. if (!empty($date_format['locales'])) { - foreach ($date_format['locales'] as $langcode) { + foreach ($date_format['locales'] as $locale) { // Only proceed if language is enabled. - if (in_array($langcode, $languages)) { - $is_existing = (bool) db_query_range('SELECT 1 FROM {date_format_locale} WHERE type = :type AND language = :language', 0, 1, array(':type' => $date_format['type'], ':language' => $langcode))->fetchField(); + if (in_array($locale, $languages)) { + $is_existing = (bool) db_query_range('SELECT 1 FROM {date_format_locale} WHERE type = :type AND language = :language', 0, 1, array(':type' => $date_format['type'], ':language' => $locale))->fetchField(); if (!$is_existing) { - $locale_format['language'] = $langcode; + $locale_format['language'] = $locale; drupal_write_record('date_format_locale', $locale_format); } } diff --git a/modules/system/system.test b/modules/system/system.test index e0d046e..038d289 100644 --- a/modules/system/system.test +++ b/modules/system/system.test @@ -1252,10 +1252,10 @@ class PageTitleFiltering extends DrupalWebTestCase { drupal_set_title($title, PASS_THROUGH); $this->assertTrue(strpos(drupal_get_title(), '') !== FALSE, t('Tags in title are not converted to entities when $output is PASS_THROUGH.')); // Generate node content. - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $edit = array( "title" => '!SimpleTest! ' . $title . $this->randomName(20), - "body[$langcode][0][value]" => '!SimpleTest! test body' . $this->randomName(200), + "body[$locale][0][value]" => '!SimpleTest! test body' . $this->randomName(200), ); // Create the node with HTML in the title. $this->drupalPost('node/add/page', $edit, t('Save')); diff --git a/modules/system/system.tokens.inc b/modules/system/system.tokens.inc index 56ddf29..bc3386d 100644 --- a/modules/system/system.tokens.inc +++ b/modules/system/system.tokens.inc @@ -133,7 +133,7 @@ function system_tokens($type, $tokens, array $data = array(), array $options = a if (isset($language)) { $url_options['language'] = $language; } - $langcode = (isset($language) ? $language->language : NULL); + $locale = (isset($language) ? $language->language : NULL); $sanitize = !empty($options['sanitize']); $replacements = array(); @@ -181,19 +181,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, $langcode); + $replacements[$original] = format_date($date, 'short', '', NULL, $locale); break; case 'medium': - $replacements[$original] = format_date($date, 'medium', '', NULL, $langcode); + $replacements[$original] = format_date($date, 'medium', '', NULL, $locale); break; case 'long': - $replacements[$original] = format_date($date, 'long', '', NULL, $langcode); + $replacements[$original] = format_date($date, 'long', '', NULL, $locale); break; case 'since': - $replacements[$original] = format_interval((REQUEST_TIME - $date), 2, $langcode); + $replacements[$original] = format_interval((REQUEST_TIME - $date), 2, $locale); break; case 'raw': @@ -204,7 +204,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, $langcode); + $replacements[$original] = format_date($date, 'custom', $name, NULL, $locale); } } } @@ -242,7 +242,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, $langcode); + $replacements[$original] = format_date($file->timestamp, 'medium', '', NULL, $locale); break; case 'owner': diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index dc2847d..bc622ce 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -693,29 +693,29 @@ function taxonomy_term_delete($tid) { * A term object. * @param $view_mode * View mode, e.g. 'full', 'teaser'... - * @param $langcode + * @param $locale * (optional) A language code to use for rendering. Defaults to the global * content language of the current request. * * @return * An array as expected by drupal_render(). */ -function taxonomy_term_view($term, $view_mode = 'full', $langcode = NULL) { - if (!isset($langcode)) { - $langcode = $GLOBALS['language_content']->language; +function taxonomy_term_view($term, $view_mode = 'full', $locale = NULL) { + if (!isset($locale)) { + $locale = $GLOBALS['language_content']->language; } - field_attach_prepare_view('taxonomy_term', array($term->tid => $term), $view_mode, $langcode); - entity_prepare_view('taxonomy_term', array($term->tid => $term), $langcode); + field_attach_prepare_view('taxonomy_term', array($term->tid => $term), $view_mode, $locale); + entity_prepare_view('taxonomy_term', array($term->tid => $term), $locale); $build = array( '#theme' => 'taxonomy_term', '#term' => $term, '#view_mode' => $view_mode, - '#language' => $langcode, + '#language' => $locale, ); - $build += field_attach_view('taxonomy_term', $term, $view_mode, $langcode); + $build += field_attach_view('taxonomy_term', $term, $view_mode, $locale); // Add term description if the term has one. if (!empty($term->description)) { @@ -1299,7 +1299,7 @@ function taxonomy_options_list($field) { * Possible error codes: * - 'taxonomy_term_illegal_value': The value is not part of the list of allowed values. */ -function taxonomy_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) { +function taxonomy_field_validate($entity_type, $entity, $field, $instance, $locale, $items, &$errors) { // Build an array of existing term IDs so they can be loaded with // taxonomy_term_load_multiple(); foreach ($items as $delta => $item) { @@ -1338,7 +1338,7 @@ function taxonomy_field_validate($entity_type, $entity, $field, $instance, $lang } } if (!$validate) { - $errors[$field['field_name']][$langcode][$delta][] = array( + $errors[$field['field_name']][$locale][$delta][] = array( 'error' => 'taxonomy_term_reference_illegal_value', 'message' => t('%name: illegal value.', array('%name' => $instance['label'])), ); @@ -1376,7 +1376,7 @@ function taxonomy_field_formatter_info() { /** * Implements hook_field_formatter_view(). */ -function taxonomy_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { +function taxonomy_field_formatter_view($entity_type, $entity, $field, $instance, $locale, $items, $display) { $element = array(); // Terms whose tid is 'autocreate' do not exist @@ -1445,7 +1445,7 @@ function taxonomy_allowed_values($field) { * This preloads all taxonomy terms for multiple loaded objects at once and * unsets values for invalid terms that do not exist. */ -function taxonomy_field_formatter_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $displays) { +function taxonomy_field_formatter_prepare_view($entity_type, $entities, $field, $instances, $locale, &$items, $displays) { $tids = array(); // Collect every possible term attached to any of the fieldable entities. @@ -1505,7 +1505,7 @@ function taxonomy_term_title($term) { /** * Implements hook_field_widget_form(). */ -function taxonomy_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) { +function taxonomy_field_widget_form(&$form, &$form_state, $field, $instance, $locale, $items, $delta, $element) { $tags = array(); foreach ($items as $item) { $tags[$item['tid']] = isset($item['taxonomy_term']) ? $item['taxonomy_term'] : taxonomy_term_load($item['tid']); @@ -1671,7 +1671,7 @@ function taxonomy_rdf_mapping() { * * Create any new terms defined in a freetagging vocabulary. */ -function taxonomy_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) { +function taxonomy_field_presave($entity_type, $entity, $field, $instance, $locale, &$items) { foreach ($items as $delta => $item) { if ($item['tid'] == 'autocreate') { $term = (object) $item; @@ -1685,7 +1685,7 @@ function taxonomy_field_presave($entity_type, $entity, $field, $instance, $langc /** * Implements hook_field_insert(). */ -function taxonomy_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) { +function taxonomy_field_insert($entity_type, $entity, $field, $instance, $locale, &$items) { // We maintain a denormalized table of term/node relationships, containing // only data for current, published nodes. if (variable_get('taxonomy_maintain_index_table', TRUE) && $field['storage']['type'] == 'field_sql_storage' && $entity_type == 'node' && $entity->status) { @@ -1705,7 +1705,7 @@ function taxonomy_field_insert($entity_type, $entity, $field, $instance, $langco /** * Implements hook_field_update(). */ -function taxonomy_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) { +function taxonomy_field_update($entity_type, $entity, $field, $instance, $locale, &$items) { if (variable_get('taxonomy_maintain_index_table', TRUE) && $field['storage']['type'] == 'field_sql_storage' && $entity_type == 'node') { $first_call = &drupal_static(__FUNCTION__, array()); diff --git a/modules/taxonomy/taxonomy.test b/modules/taxonomy/taxonomy.test index 80ddc84..f119826 100644 --- a/modules/taxonomy/taxonomy.test +++ b/modules/taxonomy/taxonomy.test @@ -436,12 +436,12 @@ class TaxonomyLegacyTestCase extends TaxonomyWebTestCase { */ function testTaxonomyLegacyNode() { // Posts an article with a taxonomy term and a date prior to 1970. - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $edit = array(); $edit['title'] = $this->randomName(); $edit['date'] = '1969-01-01 00:00:00 -0500'; - $edit["body[$langcode][0][value]"] = $this->randomName(); - $edit["field_tags[$langcode]"] = $this->randomName(); + $edit["body[$locale][0][value]"] = $this->randomName(); + $edit["field_tags[$locale]"] = $this->randomName(); $this->drupalPost('node/add/article', $edit, t('Save')); // Checks that the node has been saved. $node = $this->drupalGetNodeByTitle($edit['title']); @@ -544,10 +544,10 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase { // Post an article. $edit = array(); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $edit["title"] = $this->randomName(); - $edit["body[$langcode][0][value]"] = $this->randomName(); - $edit[$this->instance['field_name'] . '[' . $langcode .'][]'] = $term1->tid; + $edit["body[$locale][0][value]"] = $this->randomName(); + $edit[$this->instance['field_name'] . '[' . $locale .'][]'] = $term1->tid; $this->drupalPost('node/add/article', $edit, t('Save')); // Check that the term is displayed when the node is viewed. @@ -556,7 +556,7 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase { $this->assertText($term1->name, t('Term is displayed when viewing the node.')); // Edit the node with a different term. - $edit[$this->instance['field_name'] . '[' . $langcode . '][]'] = $term2->tid; + $edit[$this->instance['field_name'] . '[' . $locale . '][]'] = $term2->tid; $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save')); $this->drupalGet('node/' . $node->nid); @@ -585,12 +585,12 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase { ); $edit = array(); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $edit["title"] = $this->randomName(); - $edit["body[$langcode][0][value]"] = $this->randomName(); + $edit["body[$locale][0][value]"] = $this->randomName(); // Insert the terms in a comma separated list. Vocabulary 1 is a // free-tagging field created by the default profile. - $edit[$instance['field_name'] . "[$langcode]"] = implode(', ', $terms); + $edit[$instance['field_name'] . "[$locale]"] = implode(', ', $terms); // Preview and verify the terms appear but are not created. $this->drupalPost('node/add/page', $edit, t('Preview')); @@ -997,10 +997,10 @@ class TaxonomyTermFieldTestCase extends TaxonomyWebTestCase { */ function testTaxonomyTermFieldValidation() { // Test valid and invalid values with field_attach_validate(). - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $entity = field_test_create_stub_entity(); $term = $this->createTerm($this->vocabulary); - $entity->{$this->field_name}[$langcode][0]['tid'] = $term->tid; + $entity->{$this->field_name}[$locale][0]['tid'] = $term->tid; try { field_attach_validate('test_entity', $entity); $this->pass(t('Correct term does not cause validation error')); @@ -1011,7 +1011,7 @@ class TaxonomyTermFieldTestCase extends TaxonomyWebTestCase { $entity = field_test_create_stub_entity(); $bad_term = $this->createTerm($this->createVocabulary()); - $entity->{$this->field_name}[$langcode][0]['tid'] = $bad_term->tid; + $entity->{$this->field_name}[$locale][0]['tid'] = $bad_term->tid; try { field_attach_validate('test_entity', $entity); $this->fail(t('Wrong term causes validation error')); @@ -1029,13 +1029,13 @@ class TaxonomyTermFieldTestCase extends TaxonomyWebTestCase { $term = $this->createTerm($this->vocabulary); // Display creation form. - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $this->drupalGet('test-entity/add/test-bundle'); - $this->assertFieldByName("{$this->field_name}[$langcode]", '', t('Widget is displayed')); + $this->assertFieldByName("{$this->field_name}[$locale]", '', t('Widget is displayed')); // Submit with some value. $edit = array( - "{$this->field_name}[$langcode]" => array($term->tid), + "{$this->field_name}[$locale]" => array($term->tid), ); $this->drupalPost(NULL, $edit, t('Save')); preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match); @@ -1103,7 +1103,7 @@ class TaxonomyTokenReplaceTestCase extends TaxonomyWebTestCase { $this->admin_user = $this->drupalCreateUser(array('administer taxonomy', 'bypass node access')); $this->drupalLogin($this->admin_user); $this->vocabulary = $this->createVocabulary(); - $this->langcode = LANGUAGE_NONE; + $this->locale = LANGUAGE_NONE; $field = array( 'field_name' => 'taxonomy_' . $this->vocabulary->machine_name, @@ -1155,7 +1155,7 @@ class TaxonomyTokenReplaceTestCase extends TaxonomyWebTestCase { // Create node with term2. $edit = array(); $node = $this->drupalCreateNode(array('type' => 'article')); - $edit[$this->instance['field_name'] . '[' . $this->langcode . '][]'] = $term2->tid; + $edit[$this->instance['field_name'] . '[' . $this->locale . '][]'] = $term2->tid; $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save')); // Generate and test sanitized tokens for term1. diff --git a/modules/translation/translation.module b/modules/translation/translation.module index 697929f..4b50e80 100644 --- a/modules/translation/translation.module +++ b/modules/translation/translation.module @@ -137,8 +137,8 @@ function translation_form_node_form_alter(&$form, &$form_state) { $language_list = locale_language_list('name', TRUE); foreach (array(1, 0) as $status) { $group = $groups[$status]; - foreach ($languages[$status] as $langcode => $language) { - $options[$group][$langcode] = $language_list[$langcode]; + foreach ($languages[$status] as $locale => $language) { + $options[$group][$locale] = $language_list[$locale]; } } $form['language']['#options'] = $options; @@ -153,14 +153,14 @@ function translation_form_node_form_alter(&$form, &$form_state) { // node to some language which is already in the translation set. Also remove the // language neutral option. unset($form['language']['#options'][LANGUAGE_NONE]); - foreach (translation_node_get_translations($node->tnid) as $langcode => $translation) { + foreach (translation_node_get_translations($node->tnid) as $locale => $translation) { if ($translation->nid != $node->nid) { if ($translator_widget) { - $group = $groups[(int)!isset($disabled_languages[$langcode])]; - unset($form['language']['#options'][$group][$langcode]); + $group = $groups[(int)!isset($disabled_languages[$locale])]; + unset($form['language']['#options'][$group][$locale]); } else { - unset($form['language']['#options'][$langcode]); + unset($form['language']['#options'][$locale]); } } } @@ -221,15 +221,15 @@ function translation_node_view($node, $view_mode) { $custom_links = language_negotiation_get_switch_links($type, "node/$node->nid"); $links = array(); - foreach ($translations as $langcode => $translation) { + foreach ($translations as $locale => $translation) { // Do not show links to the same node, to unpublished translations or to // translations in disabled languages. - if ($translation->status && isset($languages[$langcode]) && $langcode != $node->language) { - $language = $languages[$langcode]; - $key = "translation_$langcode"; + if ($translation->status && isset($languages[$locale]) && $locale != $node->language) { + $language = $languages[$locale]; + $key = "translation_$locale"; - if (isset($custom_links->links[$langcode])) { - $links[$key] = $custom_links->links[$langcode]; + if (isset($custom_links->links[$locale])) { + $links[$key] = $custom_links->links[$locale]; } else { $links[$key] = array( @@ -282,8 +282,8 @@ function translation_node_prepare($node) { } $language_list = language_list(); - $langcode = $_GET['target']; - if (!isset($language_list[$langcode]) || ($source_node->language == $langcode)) { + $locale = $_GET['target']; + if (!isset($language_list[$locale]) || ($source_node->language == $locale)) { // If not supported language, or same language as source node, break. return; } @@ -291,14 +291,14 @@ function translation_node_prepare($node) { // Ensure we don't have an existing translation in this language. if (!empty($source_node->tnid)) { $translations = translation_node_get_translations($source_node->tnid); - if (isset($translations[$langcode])) { - drupal_set_message(t('A translation of %title in %language already exists, a new %type will be created instead of a translation.', array('%title' => $source_node->title, '%language' => $language_list[$langcode]->name, '%type' => $node->type)), 'error'); + if (isset($translations[$locale])) { + drupal_set_message(t('A translation of %title in %language already exists, a new %type will be created instead of a translation.', array('%title' => $source_node->title, '%language' => $language_list[$locale]->name, '%type' => $node->type)), 'error'); return; } } // Populate fields based on source node. - $node->language = $langcode; + $node->language = $locale; $node->translation_source = $source_node; $node->title = $source_node->title; @@ -520,15 +520,15 @@ function translation_language_switch_links_alter(array &$links, $type, $path) { $translations = translation_node_get_translations($node->tnid); } - foreach ($links as $langcode => $link) { - if (isset($translations[$langcode]) && $translations[$langcode]->status) { + foreach ($links as $locale => $link) { + if (isset($translations[$locale]) && $translations[$locale]->status) { // Translation in a different node. - $links[$langcode]['href'] = 'node/' . $translations[$langcode]->nid . $matches[2]; + $links[$locale]['href'] = 'node/' . $translations[$locale]->nid . $matches[2]; } else { // No translation in this language, or no permission to view. - unset($links[$langcode]['href']); - $links[$langcode]['attributes']['class'] = 'locale-untranslated'; + unset($links[$locale]['href']); + $links[$locale]['attributes']['class'] = 'locale-untranslated'; } } } diff --git a/modules/translation/translation.pages.inc b/modules/translation/translation.pages.inc index 7e4f0af..ffc6d8b 100644 --- a/modules/translation/translation.pages.inc +++ b/modules/translation/translation.pages.inc @@ -28,21 +28,21 @@ function translation_node_overview($node) { $type = variable_get('translation_language_type', LANGUAGE_TYPE_INTERFACE); $header = array(t('Language'), t('Title'), t('Status'), t('Operations')); - foreach (language_list() as $langcode => $language) { + foreach (language_list() as $locale => $language) { $options = array(); $language_name = $language->name; - if (isset($translations[$langcode])) { + if (isset($translations[$locale])) { // Existing translation in the translation set: display status. // We load the full node to check whether the user can edit it. - $translation_node = node_load($translations[$langcode]->nid); + $translation_node = node_load($translations[$locale]->nid); $path = 'node/' . $translation_node->nid; $links = language_negotiation_get_switch_links($type, $path); - $title = empty($links->links[$langcode]['href']) ? l($translation_node->title, $path) : l($translation_node->title, $links->links[$langcode]['href'], $links->links[$langcode]); + $title = empty($links->links[$locale]['href']) ? l($translation_node->title, $path) : l($translation_node->title, $links->links[$locale]['href'], $links->links[$locale]); if (node_access('update', $translation_node)) { $text = t('edit'); $path = 'node/' . $translation_node->nid . '/edit'; $links = language_negotiation_get_switch_links($type, $path); - $options[] = empty($links->links[$langcode]['href']) ? l($text, $path) : l($text, $links->links[$langcode]['href'], $links->links[$langcode]); + $options[] = empty($links->links[$locale]['href']) ? l($text, $path) : l($text, $links->links[$locale]['href'], $links->links[$locale]); } $status = $translation_node->status ? t('Published') : t('Not published'); $status .= $translation_node->translate ? ' - ' . t('outdated') . '' : ''; @@ -57,8 +57,8 @@ function translation_node_overview($node) { $text = t('add translation'); $path = 'node/add/' . str_replace('_', '-', $node->type); $links = language_negotiation_get_switch_links($type, $path); - $query = array('query' => array('translation' => $node->nid, 'target' => $langcode)); - $options[] = empty($links->links[$langcode]['href']) ? l($text, $path, $query) : l($text, $links->links[$langcode]['href'], array_merge_recursive($links->links[$langcode], $query)); + $query = array('query' => array('translation' => $node->nid, 'target' => $locale)); + $options[] = empty($links->links[$locale]['href']) ? l($text, $path, $query) : l($text, $links->links[$locale]['href'], array_merge_recursive($links->links[$locale], $query)); } $status = t('Not translated'); } diff --git a/modules/translation/translation.test b/modules/translation/translation.test index 54b53d9..a828dc1 100644 --- a/modules/translation/translation.test +++ b/modules/translation/translation.test @@ -99,9 +99,9 @@ class TranslationTestCase extends DrupalWebTestCase { // Attempt a resubmission of the form - this emulates using the back button // to return to the page then resubmitting the form without a refresh. $edit = array(); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $edit["title"] = $this->randomName(); - $edit["body[$langcode][0][value]"] = $this->randomName(); + $edit["body[$locale][0][value]"] = $this->randomName(); $this->drupalPost('node/add/page', $edit, t('Save'), array('query' => array('translation' => $node->nid, 'language' => 'es'))); $duplicate = $this->drupalGetNodeByTitle($edit["title"]); $this->assertEqual($duplicate->tnid, 0, t('The node does not have a tnid.')); @@ -263,8 +263,8 @@ class TranslationTestCase extends DrupalWebTestCase { /** * Return an empty node data structure. */ - function emptyNode($langcode) { - return (object) array('nid' => NULL, 'language' => $langcode); + function emptyNode($locale) { + return (object) array('nid' => NULL, 'language' => $locale); } /** @@ -281,7 +281,7 @@ class TranslationTestCase extends DrupalWebTestCase { if (strpos($this->drupalGetContent(), 'enabled[' . $language_code . ']') === FALSE) { // Doesn't have language installed so add it. $edit = array(); - $edit['langcode'] = $language_code; + $edit['locale'] = $language_code; $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); // Make sure we are not using a stale list. @@ -317,9 +317,9 @@ class TranslationTestCase extends DrupalWebTestCase { */ function createPage($title, $body, $language = NULL) { $edit = array(); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $edit["title"] = $title; - $edit["body[$langcode][0][value]"] = $body; + $edit["body[$locale][0][value]"] = $body; if (!empty($language)) { $edit['language'] = $language; } diff --git a/modules/trigger/trigger.test b/modules/trigger/trigger.test index 9a9a4ba..849adf8 100644 --- a/modules/trigger/trigger.test +++ b/modules/trigger/trigger.test @@ -76,9 +76,9 @@ class TriggerContentTestCase extends TriggerWebTestCase { // Create an unpublished node. $this->drupalLogin($web_user); $edit = array(); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $edit["title"] = '!SimpleTest test node! ' . $this->randomName(10); - $edit["body[$langcode][0][value]"] = '!SimpleTest test body! ' . $this->randomName(32) . ' ' . $this->randomName(32); + $edit["body[$locale][0][value]"] = '!SimpleTest test body! ' . $this->randomName(32) . ' ' . $this->randomName(32); $edit[$info['property']] = !$info['expected']; $this->drupalPost('node/add/page', $edit, t('Save')); // Make sure the text we want appears. @@ -717,9 +717,9 @@ class TriggerOrphanedActionsTestCase extends DrupalWebTestCase { $web_user = $this->drupalCreateUser(array('create page content', 'edit own page content', 'access content', 'administer nodes')); $this->drupalLogin($web_user); $edit = array(); - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $edit["title"] = '!SimpleTest test node! ' . $this->randomName(10); - $edit["body[$langcode][0][value]"] = '!SimpleTest test body! ' . $this->randomName(32) . ' ' . $this->randomName(32); + $edit["body[$locale][0][value]"] = '!SimpleTest test body! ' . $this->randomName(32) . ' ' . $this->randomName(32); $this->drupalPost('node/add/page', $edit, t('Save')); $this->assertRaw(t('!post %title has been created.', array('!post' => 'Basic page', '%title' => $edit["title"])), t('Make sure the Basic page has actually been created')); @@ -730,7 +730,7 @@ class TriggerOrphanedActionsTestCase extends DrupalWebTestCase { // doesn't white screen. module_disable(array('trigger_test')); $loaded_node = $this->drupalGetNodeByTitle($edit["title"]); - $edit["body[$langcode][0][value]"] = '!SimpleTest test body! ' . $this->randomName(32) . ' ' . $this->randomName(32); + $edit["body[$locale][0][value]"] = '!SimpleTest test body! ' . $this->randomName(32) . ' ' . $this->randomName(32); $this->drupalPost("node/$loaded_node->nid/edit", $edit, t('Save')); // If the node body was updated successfully we have dealt with the diff --git a/modules/update/update.module b/modules/update/update.module index a2d705a..acc2deb 100644 --- a/modules/update/update.module +++ b/modules/update/update.module @@ -499,14 +499,14 @@ function _update_get_cached_available_releases() { */ function update_mail($key, &$message, $params) { $language = $message['language']; - $langcode = $language->language; - $message['subject'] .= t('New release(s) available for !site_name', array('!site_name' => variable_get('site_name', 'Drupal')), array('langcode' => $langcode)); + $locale = $language->language; + $message['subject'] .= t('New release(s) available for !site_name', array('!site_name' => variable_get('site_name', 'Drupal')), array('locale' => $locale)); foreach ($params as $msg_type => $msg_reason) { $message['body'][] = _update_message_text($msg_type, $msg_reason, FALSE, $language); } - $message['body'][] = t('See the available updates page for more information:', array(), array('langcode' => $langcode)) . "\n" . url('admin/reports/updates', array('absolute' => TRUE, 'language' => $language)); + $message['body'][] = t('See the available updates page for more information:', array(), array('locale' => $locale)) . "\n" . url('admin/reports/updates', array('absolute' => TRUE, 'language' => $language)); if (update_manager_access()) { - $message['body'][] = t('You can automatically install your missing updates using the Update manager:', array(), array('langcode' => $langcode)) . "\n" . url('admin/reports/updates/update', array('absolute' => TRUE, 'language' => $language)); + $message['body'][] = t('You can automatically install your missing updates using the Update manager:', array(), array('locale' => $locale)) . "\n" . url('admin/reports/updates/update', array('absolute' => TRUE, 'language' => $language)); } $settings_url = url('admin/reports/updates/settings', array('absolute' => TRUE)); if (variable_get('update_notification_threshold', 'all') == 'all') { @@ -538,42 +538,42 @@ function update_mail($key, &$message, $params) { * The properly translated error message for the given key. */ function _update_message_text($msg_type, $msg_reason, $report_link = FALSE, $language = NULL) { - $langcode = isset($language) ? $language->language : NULL; + $locale = isset($language) ? $language->language : NULL; $text = ''; switch ($msg_reason) { case UPDATE_NOT_SECURE: if ($msg_type == 'core') { - $text = t('There is a security update available for your version of Drupal. To ensure the security of your server, you should update immediately!', array(), array('langcode' => $langcode)); + $text = t('There is a security update available for your version of Drupal. To ensure the security of your server, you should update immediately!', array(), array('locale' => $locale)); } else { - $text = t('There are security updates available for one or more of your modules or themes. To ensure the security of your server, you should update immediately!', array(), array('langcode' => $langcode)); + $text = t('There are security updates available for one or more of your modules or themes. To ensure the security of your server, you should update immediately!', array(), array('locale' => $locale)); } break; case UPDATE_REVOKED: if ($msg_type == 'core') { - $text = t('Your version of Drupal has been revoked and is no longer available for download. Upgrading is strongly recommended!', array(), array('langcode' => $langcode)); + $text = t('Your version of Drupal has been revoked and is no longer available for download. Upgrading is strongly recommended!', array(), array('locale' => $locale)); } else { - $text = t('The installed version of at least one of your modules or themes has been revoked and is no longer available for download. Upgrading or disabling is strongly recommended!', array(), array('langcode' => $langcode)); + $text = t('The installed version of at least one of your modules or themes has been revoked and is no longer available for download. Upgrading or disabling is strongly recommended!', array(), array('locale' => $locale)); } break; case UPDATE_NOT_SUPPORTED: if ($msg_type == 'core') { - $text = t('Your version of Drupal is no longer supported. Upgrading is strongly recommended!', array(), array('langcode' => $langcode)); + $text = t('Your version of Drupal is no longer supported. Upgrading is strongly recommended!', array(), array('locale' => $locale)); } else { - $text = t('The installed version of at least one of your modules or themes is no longer supported. Upgrading or disabling is strongly recommended. See the project homepage for more details.', array(), array('langcode' => $langcode)); + $text = t('The installed version of at least one of your modules or themes is no longer supported. Upgrading or disabling is strongly recommended. See the project homepage for more details.', array(), array('locale' => $locale)); } break; case UPDATE_NOT_CURRENT: if ($msg_type == 'core') { - $text = t('There are updates available for your version of Drupal. To ensure the proper functioning of your site, you should update as soon as possible.', array(), array('langcode' => $langcode)); + $text = t('There are updates available for your version of Drupal. To ensure the proper functioning of your site, you should update as soon as possible.', array(), array('locale' => $locale)); } else { - $text = t('There are updates available for one or more of your modules or themes. To ensure the proper functioning of your site, you should update as soon as possible.', array(), array('langcode' => $langcode)); + $text = t('There are updates available for one or more of your modules or themes. To ensure the proper functioning of your site, you should update as soon as possible.', array(), array('locale' => $locale)); } break; @@ -582,20 +582,20 @@ function _update_message_text($msg_type, $msg_reason, $report_link = FALSE, $lan case UPDATE_NOT_FETCHED: case UPDATE_FETCH_PENDING: if ($msg_type == 'core') { - $text = t('There was a problem checking available updates for Drupal.', array('@update-report' => url('admin/reports/updates')), array('langcode' => $langcode)); + $text = t('There was a problem checking available updates for Drupal.', array('@update-report' => url('admin/reports/updates')), array('locale' => $locale)); } else { - $text = t('There was a problem checking available updates for your modules or themes.', array('@update-report' => url('admin/reports/updates')), array('langcode' => $langcode)); + $text = t('There was a problem checking available updates for your modules or themes.', array('@update-report' => url('admin/reports/updates')), array('locale' => $locale)); } break; } if ($report_link) { if (update_manager_access()) { - $text .= ' ' . t('See the available updates page for more information and to install your missing updates.', array('@available_updates' => url('admin/reports/updates/update', array('language' => $language))), array('langcode' => $langcode)); + $text .= ' ' . t('See the available updates page for more information and to install your missing updates.', array('@available_updates' => url('admin/reports/updates/update', array('language' => $language))), array('locale' => $locale)); } else { - $text .= ' ' . t('See the available updates page for more information.', array('@available_updates' => url('admin/reports/updates', array('language' => $language))), array('langcode' => $langcode)); + $text .= ' ' . t('See the available updates page for more information.', array('@available_updates' => url('admin/reports/updates', array('language' => $language))), array('locale' => $locale)); } } diff --git a/modules/user/user.api.php b/modules/user/user.api.php index 069a9f8..e3b1457 100644 --- a/modules/user/user.api.php +++ b/modules/user/user.api.php @@ -320,13 +320,13 @@ function hook_user_logout($account) { * The user object on which the operation is being performed. * @param $view_mode * View mode, e.g. 'full'. - * @param $langcode + * @param $locale * The language code used for rendering. * * @see hook_user_view_alter() * @see hook_entity_view() */ -function hook_user_view($account, $view_mode, $langcode) { +function hook_user_view($account, $view_mode, $locale) { if (user_access('create blog content', $account)) { $account->content['summary']['blog'] = array( '#type' => 'user_profile_item', diff --git a/modules/user/user.module b/modules/user/user.module index 044ad46..52becfd 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -2507,20 +2507,20 @@ function user_view_page($account) { * A user object. * @param $view_mode * View mode, e.g. 'full'. - * @param $langcode + * @param $locale * (optional) A language code to use for rendering. Defaults to the global * content language of the current request. * * @return * An array as expected by drupal_render(). */ -function user_view($account, $view_mode = 'full', $langcode = NULL) { - if (!isset($langcode)) { - $langcode = $GLOBALS['language_content']->language; +function user_view($account, $view_mode = 'full', $locale = NULL) { + if (!isset($locale)) { + $locale = $GLOBALS['language_content']->language; } // Retrieve all profile fields and attach to $account->content. - user_build_content($account, $view_mode, $langcode); + user_build_content($account, $view_mode, $locale); $build = $account->content; // We don't need duplicate rendering info in account->content. @@ -2530,7 +2530,7 @@ function user_view($account, $view_mode = 'full', $langcode = NULL) { '#theme' => 'user_profile', '#account' => $account, '#view_mode' => $view_mode, - '#language' => $langcode, + '#language' => $locale, ); // Allow modules to modify the structured user. @@ -2547,26 +2547,26 @@ function user_view($account, $view_mode = 'full', $langcode = NULL) { * A user object. * @param $view_mode * View mode, e.g. 'full'. - * @param $langcode + * @param $locale * (optional) A language code to use for rendering. Defaults to the global * content language of the current request. */ -function user_build_content($account, $view_mode = 'full', $langcode = NULL) { - if (!isset($langcode)) { - $langcode = $GLOBALS['language_content']->language; +function user_build_content($account, $view_mode = 'full', $locale = NULL) { + if (!isset($locale)) { + $locale = $GLOBALS['language_content']->language; } // Remove previously built content, if exists. $account->content = array(); // Build fields content. - field_attach_prepare_view('user', array($account->uid => $account), $view_mode, $langcode); - entity_prepare_view('user', array($account->uid => $account), $langcode); - $account->content += field_attach_view('user', $account, $view_mode, $langcode); + field_attach_prepare_view('user', array($account->uid => $account), $view_mode, $locale); + entity_prepare_view('user', array($account->uid => $account), $locale); + $account->content += field_attach_view('user', $account, $view_mode, $locale); // Populate $account->content with a render() array. - module_invoke_all('user_view', $account, $view_mode, $langcode); - module_invoke_all('entity_view', $account, 'user', $view_mode, $langcode); + module_invoke_all('user_view', $account, $view_mode, $locale); + module_invoke_all('entity_view', $account, 'user', $view_mode, $locale); } /** @@ -2585,7 +2585,7 @@ function user_mail($key, &$message, $params) { * Used by user_mail() and the settings forms to retrieve strings. */ function _user_mail_text($key, $language = NULL, $variables = array(), $replace = TRUE) { - $langcode = isset($language) ? $language->language : NULL; + $locale = isset($language) ? $language->language : NULL; if ($admin_setting = variable_get('user_mail_' . $key, FALSE)) { // An admin setting overrides the default string. @@ -2595,7 +2595,7 @@ function _user_mail_text($key, $language = NULL, $variables = array(), $replace // No override, return default string. switch ($key) { case 'register_no_approval_required_subject': - $text = t('Account details for [user:name] at [site:name]', array(), array('langcode' => $langcode)); + $text = t('Account details for [user:name] at [site:name]', array(), array('locale' => $locale)); break; case 'register_no_approval_required_body': $text = t("[user:name], @@ -2611,11 +2611,11 @@ After setting your password, you will be able to log in at [site:login-url] in t username: [user:name] password: Your password --- [site:name] team", array(), array('langcode' => $langcode)); +-- [site:name] team", array(), array('locale' => $locale)); break; case 'register_admin_created_subject': - $text = t('An administrator created an account for you at [site:name]', array(), array('langcode' => $langcode)); + $text = t('An administrator created an account for you at [site:name]', array(), array('locale' => $locale)); break; case 'register_admin_created_body': $text = t("[user:name], @@ -2631,12 +2631,12 @@ After setting your password, you will be able to log in at [site:login-url] in t username: [user:name] password: Your password --- [site:name] team", array(), array('langcode' => $langcode)); +-- [site:name] team", array(), array('locale' => $locale)); break; case 'register_pending_approval_subject': case 'register_pending_approval_admin_subject': - $text = t('Account details for [user:name] at [site:name] (pending admin approval)', array(), array('langcode' => $langcode)); + $text = t('Account details for [user:name] at [site:name] (pending admin approval)', array(), array('locale' => $locale)); break; case 'register_pending_approval_body': $text = t("[user:name], @@ -2644,16 +2644,16 @@ password: Your password Thank you for registering at [site:name]. Your application for an account is currently pending approval. Once it has been approved, you will receive another e-mail containing information about how to log in, set your password, and other details. --- [site:name] team", array(), array('langcode' => $langcode)); +-- [site:name] team", array(), array('locale' => $locale)); break; case 'register_pending_approval_admin_body': $text = t("[user:name] has applied for an account. -[user:edit-url]", array(), array('langcode' => $langcode)); +[user:edit-url]", array(), array('locale' => $locale)); break; case 'password_reset_subject': - $text = t('Replacement login information for [user:name] at [site:name]', array(), array('langcode' => $langcode)); + $text = t('Replacement login information for [user:name] at [site:name]', array(), array('locale' => $locale)); break; case 'password_reset_body': $text = t("[user:name], @@ -2666,11 +2666,11 @@ You may now log in by clicking this link or copying and pasting it to your brows This link can only be used once to log in and will lead you to a page where you can set your password. It expires after one day and nothing will happen if it's not used. --- [site:name] team", array(), array('langcode' => $langcode)); +-- [site:name] team", array(), array('locale' => $locale)); break; case 'status_activated_subject': - $text = t('Account details for [user:name] at [site:name] (approved)', array(), array('langcode' => $langcode)); + $text = t('Account details for [user:name] at [site:name] (approved)', array(), array('locale' => $locale)); break; case 'status_activated_body': $text = t("[user:name], @@ -2688,22 +2688,22 @@ After setting your password, you will be able to log in at [site:login-url] in t username: [user:name] password: Your password --- [site:name] team", array(), array('langcode' => $langcode)); +-- [site:name] team", array(), array('locale' => $locale)); break; case 'status_blocked_subject': - $text = t('Account details for [user:name] at [site:name] (blocked)', array(), array('langcode' => $langcode)); + $text = t('Account details for [user:name] at [site:name] (blocked)', array(), array('locale' => $locale)); break; case 'status_blocked_body': $text = t("[user:name], Your account on [site:name] has been blocked. --- [site:name] team", array(), array('langcode' => $langcode)); +-- [site:name] team", array(), array('locale' => $locale)); break; case 'cancel_confirm_subject': - $text = t('Account cancellation request for [user:name] at [site:name]', array(), array('langcode' => $langcode)); + $text = t('Account cancellation request for [user:name] at [site:name]', array(), array('locale' => $locale)); break; case 'cancel_confirm_body': $text = t("[user:name], @@ -2718,18 +2718,18 @@ NOTE: The cancellation of your account is not reversible. This link expires in one day and nothing will happen if it is not used. --- [site:name] team", array(), array('langcode' => $langcode)); +-- [site:name] team", array(), array('locale' => $locale)); break; case 'status_canceled_subject': - $text = t('Account details for [user:name] at [site:name] (canceled)', array(), array('langcode' => $langcode)); + $text = t('Account details for [user:name] at [site:name] (canceled)', array(), array('locale' => $locale)); break; case 'status_canceled_body': $text = t("[user:name], Your account on [site:name] has been canceled. --- [site:name] team", array(), array('langcode' => $langcode)); +-- [site:name] team", array(), array('locale' => $locale)); break; } } diff --git a/modules/user/user.test b/modules/user/user.test index 6ecbfac..464d88a 100644 --- a/modules/user/user.test +++ b/modules/user/user.test @@ -724,10 +724,10 @@ class UserCancelTestCase extends DrupalWebTestCase { $node = $this->drupalCreateNode(array('uid' => $account->uid)); // Create comment. - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $edit = array(); $edit['subject'] = $this->randomName(8); - $edit['comment_body[' . $langcode . '][0][value]'] = $this->randomName(16); + $edit['comment_body[' . $locale . '][0][value]'] = $this->randomName(16); $this->drupalPost('comment/reply/' . $node->nid, $edit, t('Preview')); $this->drupalPost(NULL, array(), t('Save')); @@ -1733,10 +1733,10 @@ class UserSignatureTestCase extends DrupalWebTestCase { $this->assertFieldByName('signature[format]', $edit['signature[format]'], 'Submitted signature format found.'); // Create a comment. - $langcode = LANGUAGE_NONE; + $locale = LANGUAGE_NONE; $edit = array(); $edit['subject'] = $this->randomName(8); - $edit['comment_body[' . $langcode . '][0][value]'] = $this->randomName(16); + $edit['comment_body[' . $locale . '][0][value]'] = $this->randomName(16); $this->drupalPost('comment/reply/' . $node->nid, $edit, t('Preview')); $this->drupalPost(NULL, array(), t('Save')); @@ -1748,7 +1748,7 @@ class UserSignatureTestCase extends DrupalWebTestCase { // Log in as an administrator and edit the comment to use Full HTML, so // that the comment text itself is not filtered at all. $this->drupalLogin($this->admin_user); - $edit['comment_body[' . $langcode . '][0][format]'] = $this->full_html_format->format; + $edit['comment_body[' . $locale . '][0][format]'] = $this->full_html_format->format; $this->drupalPost('comment/' . $comment_id . '/edit', $edit, t('Save')); // Assert that the signature did not make it through unfiltered.