summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/field/tests/field.test3
-rw-r--r--modules/locale/locale.module19
-rw-r--r--modules/locale/locale.test7
3 files changed, 12 insertions, 17 deletions
diff --git a/modules/field/tests/field.test b/modules/field/tests/field.test
index 7468653b1..d25f120fc 100644
--- a/modules/field/tests/field.test
+++ b/modules/field/tests/field.test
@@ -2576,8 +2576,9 @@ class FieldTranslationsTestCase extends FieldTestCase {
field_create_instance($instance);
$this->instance = field_read_instance('test_entity', $this->field_name, 'test_bundle');
+ require_once DRUPAL_ROOT . '/includes/locale.inc';
for ($i = 0; $i < 3; ++$i) {
- locale_inc_callback('locale_add_language', 'l' . $i, $this->randomString(), $this->randomString());
+ locale_add_language('l' . $i, $this->randomString(), $this->randomString());
}
}
diff --git a/modules/locale/locale.module b/modules/locale/locale.module
index 7f308ff93..b091f12af 100644
--- a/modules/locale/locale.module
+++ b/modules/locale/locale.module
@@ -273,16 +273,6 @@ function locale_init() {
}
/**
- * Wrapper function to be able to set callbacks in locale.inc
- */
-function locale_inc_callback() {
- $args = func_get_args();
- $function = array_shift($args);
- include_once DRUPAL_ROOT . '/includes/locale.inc';
- return call_user_func_array($function, $args);
-}
-
-/**
* Implements hook_permission().
*/
function locale_permission() {
@@ -766,6 +756,9 @@ function locale_js_alter(&$javascript) {
$parsed = variable_get('javascript_parsed', array());
$files = $new_files = FALSE;
+ // Require because locale_js_alter() could be called without locale_init().
+ require_once DRUPAL_ROOT . '/includes/locale.inc';
+
foreach ($javascript as $item) {
if ($item['type'] == 'file') {
$files = TRUE;
@@ -773,7 +766,7 @@ function locale_js_alter(&$javascript) {
if (!in_array($filepath, $parsed)) {
// Don't parse our own translations files.
if (substr($filepath, 0, strlen($dir)) != $dir) {
- locale_inc_callback('_locale_parse_js_file', $filepath);
+ _locale_parse_js_file($filepath);
$parsed[] = $filepath;
$new_files = TRUE;
}
@@ -785,14 +778,14 @@ function locale_js_alter(&$javascript) {
// JavaScript translation files for all languages, adding the refresh
// flags into the existing array.
if ($new_files) {
- $parsed += locale_inc_callback('_locale_invalidate_js');
+ $parsed += _locale_invalidate_js();
}
// If necessary, rebuild the translation file for the current language.
if (!empty($parsed['refresh:' . $language->language])) {
// Don't clear the refresh flag on failure, so that another try will
// be performed later.
- if (locale_inc_callback('_locale_rebuild_js')) {
+ if (_locale_rebuild_js()) {
unset($parsed['refresh:' . $language->language]);
}
// Store any changes after refresh was attempted.
diff --git a/modules/locale/locale.test b/modules/locale/locale.test
index 4bfb09cc7..33fc3ab4a 100644
--- a/modules/locale/locale.test
+++ b/modules/locale/locale.test
@@ -334,7 +334,8 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
$this->drupalPost($url, $edit, t('Save translations'));
// Trigger JavaScript translation parsing and building.
- locale_inc_callback('_locale_rebuild_js', $langcode);
+ require_once DRUPAL_ROOT . '/includes/locale.inc';
+ _locale_rebuild_js($langcode);
// Retrieve the JavaScript translation hash code for the custom language to
// check that the translation file has been properly built.
@@ -350,7 +351,7 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
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_inc_callback('_locale_rebuild_js', $langcode);
+ _locale_rebuild_js($langcode);
$this->assertTrue($result = file_exists($js_file), t('JavaScript file rebuilt: %file', array('%file' => $result ? $js_file : t('not found'))));
}
@@ -1534,7 +1535,7 @@ class UILanguageNegotiationTest extends DrupalWebTestCase {
$language_domain = 'example.cn';
// Setup the site languages by installing two languages.
- require_once('includes/locale.inc');
+ require_once DRUPAL_ROOT . '/includes/locale.inc';
locale_add_language($language_browser_fallback);
locale_add_language($language);