During a recent Lullboat podcast we mentioned a new feature in Drupal 6 that allows you replace any string in Drupal without using Locale module (thanks Moshe!). Faithful podcast listener Rob Loach took it upon himself to write the String Overrides module that lets you accomplish this task with ease in Drupal 6. While Lullabots were lamenting the fact that this feature was never in Drupal 5, we realized that it actually could be accomplished. An hour after undertaking the project, the patch was submitted to the String Overrides queue and committed shortly afterwards. String Overrides accomplishes this in Drupal 5 by imitating the Locale module, and without hitting the database (since variables are cached and pulled up on every request anyway). Since this essentially a hack for Drupal 5, you cannot combine it with Locale module or languages other than English. Here's the key code that makes this possible:
 * Fake the locale function.
if (!function_exists('locale')) {
  function locale_supported_languages($reset = FALSE, $getall = FALSE) {
    return array(
      'name' => array('xx' => 'String Overrides'),
      'formula' => array('xx' => ''),

  function locale($string) {
    static $strings = array();
    $strings = variable_get('locale_custom_strings_en', array());
    if ($strings[$string]) {
    	return $strings[$string];
    else {
    	return $string;
Basically String Overrides pretends that it is Locale module and does the translation without hitting the database. Because it uses the same variable format as the Drupal 6 core feature, when the site upgrades to Drupal 6 the hack is no longer necessary and the site becomes compatible with Locale module again. For anyone needing to change just a few words on their Drupal site, String Overrides is a great solution.

In Action



Nate Lampton

Nate Lampton standing in front of greenery.
Nate Lampton is a leader in Open Source with over a decade of contributions to the Drupal project. He joined Lullabot in 2006.

Featured Work

Latest Resources

Latest Podcasts

Let's Connect

Want to learn more about working with us or just say hello?

Contact Us