2

I noticed that most of my Russian clients afraid "Таксономия" ("taxonomy") word, because the word sounds like something very complex and incomprehensible for them:)

I want to change all iterations of "Таксономия" to another word, for example to "Классификация", because this word is familiar to everyone in Russia.

So how can I change one word to another in ALL iterations of the word in translate system ON EXISTING site. In other words, how can I bulk update translation by some algorithm instead of edit each string manually?

4

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

  1. 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". Be sure to take note of the permissions and change them back to what they were afterwards.
    • The default settings file is in drupal_root_folder/sites/default/settings.php
  2. Look for this code at the bottom

    # $conf['locale_custom_strings_en'][''] = array(
    #   'Old string 1'      => 'New string 1',
    #   'Old string 2'      => 'New string 2',
    # );
    
  3. Remove the comment marks ('#') and add string replacement assignments:

Method 2: String Overrides module

Pros

  • Admin page for managing string replacements.
  • Uses access permissions. Easier to delegate management of replacements.

Cons

  • Yet another module to install, update, and administer.
  • Possible performance hit and more difficulty to deploy (stores replacements in the database).
  • Uses access permissions. Harder to restrict changes when you have to give administrator access to others.

Procedure

  1. Install and enable the module.
  2. Follow the instructions / documentation for adding string replacements.

Method 3: hook_boot()

Procedure

  1. Implement the hook_boot()
  2. Use the same array as in the settings.php.

    /**
      * Implements hook_boot().
      */
     function mymodule_boot() {
       global $conf;
       $conf['locale_custom_strings_en'][''] = array(
         'Old string 1'      => 'New string 1',
         'Old string 2'      => 'New string 2',
       );
     }
    

Method 4: Replace all the strings in the database

Procedure

  1. Dump the database to a text file.

    mysqldump -u user -p databasename > ./db.sql
    
  2. Run a sed command to find/replace target string

    sed -i 's/oldString/newString/g' ./db.sql
    
  3. Reload the database back into MySQL.

    mysql -u user -p databasename < ./db.sql
    

Note: All commands are bash commands on Linux, but you can replace them with another method.

References:

| improve this answer | |
1

I found the following fast, easy and safe way to replace strings in translation.

1) export translation to .po file

2) open .po in text editor and autoreplace all iterations of the string.

3) import the .po file with replacing option

| improve this answer | |
  • 1
    Yes, but if you have more then one module with the word (taxonomy in this case), you will need to exporte more than one file. – Adrian Cid Almaguer Jan 28 '16 at 0:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.