Drupal 4.7: Creating a customized language set to replace Drupal terminology

Depending on your particular application, you may find that the default text or terminology used in the Drupal core or a contributed module doesn't suit your style or need. Customizing this text with the locale module is fairly simple and is portable if you create an additional site up upgrade your version of Drupal or a contributed module.

As simple examples, you might wish to change the "Search" button to say "Find", or you might wish that comments were shown as being "Posted by" rather than "Submitted by" a particular user. As a more advanced possibility, you might wish that the things described by Drupal as "forums" were instead called "bulletin boards", and that you could change this in every context where the word "forum" is used.

The locale module is a well-developed system for handling this situation. While described as a system for making translations, it will also efficiently substitute your prefered terminology for the default Drupal terminology. You should first read the instructions for Creating a customized language set to replace Drupal terminology. After following the steps outlined there to create your custom language, this page is intended to provide additional step-by-step and detailed instructions for those new to Drupal.

Again, before proceeding, follow the instructions in the first section at http://drupal.org/node/24593 to enable the locale module, create a customized language, and make it the default language. If you are not user #1, a user with appropriate access will need to go to the access control page at administer >> access control and enable "administer locales" for your user role.

Next, rather than searching for individual strings through the interface at administer >> localization, you'll probably find it easier to use a template file and then import the "translated" strings. So, download the translation templates from the appropriate version of Drupal. Some contributed modules will also include a translation template in a "po" directory.

In the downloaded directory of templates, you will see numerous template files ending in ".pot". The file "general.pot" contains strings that are reused in several modules. Open this in a text editor and look it over. Following through on the simple examples above, we can find these strings in the file in the following form:

#: includes/locale.inc:327;346 modules/search.module:142;996 modules/system.module:1198 modules/user.module:1958
msgid "Search"
msgstr ""

Edit the file so as to specify a replacement text, such as:

#: includes/locale.inc:327;346 modules/search.module:142;996 modules/system.module:1198 modules/user.module:1958
msgid "Search"
msgstr "Find"

Similarly, we can change the text shown by each comment by making a change to this entry:

#: themes/engines/phptemplate/phptemplate.engine:250;273
msgid "Submitted by %a on %b."
msgstr "Posted by %a on %b."

Note that the text following the "#:" is for information only and does not affect the outcome of this process.

From here, save your edited file somewhere handy (you might keep it together with your local copy of your customized theme). Now go back to administer->localization and choose "import" from the top tabs. Browse and choose your edited translation file, and then import it into your customized language. Voila, you should see that the name of the Search box it changed to "Find", etc.

For a more sweeping change, you could open the "forum-module.pot file", and provide an alternate term every place the word "forum" is used. For example, you could edit the following entry as shown:

#: modules/forum.module:51;110;216
msgid "forum topic"
msgstr "bulletin board subject"

Additional help and techniques for using the locale module and generating substitute text can be found in the Translator's guide.

Note for the curious

If you look in the PHP code for a module, you'll find (for example) in the search.module:

<?php
  $form
['basic']['inline']['submit'] = array('#type' => 'submit', '#value' => t('Search'));
?>

'Search' is a t-ified string, which means it can be replaced by using the locale module.

 
 

Drupal is a registered trademark of Dries Buytaert.