Drupal: Changing default strings (text) without using full translation system
07/16/2009
Methods
- Edit settings.php file
- String Overrides module
Method 1: Edit settings.php file
Pros
- Quick method for small number of strings.
- Less accessible in cases where you want to retain some control even after granting administrator access.
Cons
- English only.
- No admin pages, requires access to files on server (FTP / SFTP / SSH). Difficult to delegate changes to non-developers.
Procedure
- Edit settings.php for the site in question.
- You’ll need to either download the file, edit it, and re-upload it, or edit it in place on the server. Of course, make a backup.
- Either way, you’ll probably need to temporarily change the permissions of the file and its containing folder to to give you “write access”. When done, be sure to change them back to what they were.
- The default settings file is in
drupal_root_folder/sites/default/settings.php
- Look for this code at the bottom:
# $conf['locale_custom_strings_en'] = array(
# 'forum' => 'Discussion board',
# '@count min' => '@count minutes',
# );
- Remove the comment marks (’#') and add string replacement assignments:
$conf['locale_custom_strings_en'] = array(
'Old string 1' => 'New string 1',
'Old string 2' => 'New string 2',
);
Method 2: String Overrides module
(http://drupal.org/project/stringoverrides)
Pros
- Admin page for managing string replacements.
- Uses access permissions. Easier to delegate management of overrides.
Cons
- Yet another module to install, update, and administer.
- Possible performance hit. Stores replacements in the database.
- Uses access permissions. Harder to restrict changes when you have to give administrator access to others.
Procedure
- Install and enable the module.
- Follow the instructions / documentation for adding string overrides.