In D7 I sometimes found use for the stringoverrides module to replace certain text strings, such as that shown in a status message.

Specifically, I want to alter the error message "The name xxxxxxx is already taken." when a new user registers and replace it with "The name xxxxxxx is already taken. Please choose another username."

What would be the most effective and simple way to make this change in BackdropCMS?

Thanks,

Martin

Accepted answer

First, I wouldn't call it "doing something wrong" but maybe not knowing a strange  behavior of the translation system: It happens that after enabling Locale and Language, the string in question has to be used  by the system at least once, so that the translation system is aware of it.

To find the missing string in the translation interface, enable User registration, try to register with an existing name, and look for the message "The name %name is already taken.". After that, the string should be available in the translation interface.

Most helpful answers

Another option if it's just a few tweaks and you don't need a UI is to modify the settings.php file:

/**
 * String overrides:
 *
 * To override specific strings on your site with or without enabling locale
 * module, add an entry to this list. This functionality allows you to change
 * a small number of your site's default English language interface strings.
 *
 * Uncomment the lines below to enable.
 */
/*
$settings['locale_custom_strings_en'][''] = array(
  'forum'      => 'Discussion board',
  '@count min' => '@count minutes',
);
*/

The user interface translation allows to 'translate' the interface from English to English, making it possible to replace individual language strings. I was able to do so following these steps:

  • Enable the core modules Language and Locale.
  • Go to Configuration > Regional and language > Languages.
  • Configure English, tick the option "Enable interface translation to English", and save the configuration.
  • Go to Configuration > Regional and language > Languages > User interface translation, search for the string "The name %name is already taken.", and 'translate' it with the string of your choice.
     

Comments

Olafski's picture

The user interface translation allows to 'translate' the interface from English to English, making it possible to replace individual language strings. I was able to do so following these steps:

  • Enable the core modules Language and Locale.
  • Go to Configuration > Regional and language > Languages.
  • Configure English, tick the option "Enable interface translation to English", and save the configuration.
  • Go to Configuration > Regional and language > Languages > User interface translation, search for the string "The name %name is already taken.", and 'translate' it with the string of your choice.
     

Thanks for that suggestion @Olafski. However, when I follow your instructions and go to  Configuration > Regional and language > User interface translation (at admin/config/regional/translate) and search for any part of "The name %name is already taken." it returns no matches. 

Any idea what am I doing wrong?

 

Olafski's picture

First, I wouldn't call it "doing something wrong" but maybe not knowing a strange  behavior of the translation system: It happens that after enabling Locale and Language, the string in question has to be used  by the system at least once, so that the translation system is aware of it.

To find the missing string in the translation interface, enable User registration, try to register with an existing name, and look for the message "The name %name is already taken.". After that, the string should be available in the translation interface.

I didn't realise that - now working perfectly. Thanks for your help Olafski!

Another option if it's just a few tweaks and you don't need a UI is to modify the settings.php file:

/**
 * String overrides:
 *
 * To override specific strings on your site with or without enabling locale
 * module, add an entry to this list. This functionality allows you to change
 * a small number of your site's default English language interface strings.
 *
 * Uncomment the lines below to enable.
 */
/*
$settings['locale_custom_strings_en'][''] = array(
  'forum'      => 'Discussion board',
  '@count min' => '@count minutes',
);
*/