Help with i18n multilingual variables in global.inc

butler360's picture

Since settings.php gets overwritten during migrations or verifications I want to put the i18n variables into global.inc, but only apply them if i18n is enabled.

I've put the following code into global.inc:

if (module_exists('i18n')) {
    $conf['i18n_variables'] = array(
    'site_name',
'site_slogan',
   'site_mission',
  );
}

As soon as I save the change, though, I get this WSOD error on all sites:

Fatal error: Call to undefined function module_exists() in /var/aegir/config/includes/global.inc on line 23

Any idea why that is?

Comments

Bootstrapping

skwashd's picture

Let me start with my standard i18n disclaimer I am very lucky, I was born in an English speaking country, I live in an English speaking country, I am fluent in at least 3 languages - English, PHP and Javascript :) I know very little about the internals of i18n within Drupal.

settings.php gets included very early on in the Drupal bootstrap process. Without debugging this one, I am pretty confident that module_exists() isn't defined at the point where settings.php is included. What harm is there in including the variables regardless? From what I know of module_exists() the overhead of defining an extra array on each page load will be less expensive than invoking the function anyway.

At the risk of publicly displaying my Drupal i18n ignorance, if this is really is really only needed when the i18n module is enabled, is it possible to implement this in a hack module and only enable that module in the sites which need it?

Thanks for the info. Hmm, if

butler360's picture

Thanks for the info. Hmm, if that's the case maybe I should just use local.settings.php and forget about module_exists.

That should work

skwashd's picture

With the little knowledge I have of the i18n stuff, that sounds like a good solution.

Aegir hosting system

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: