How to Change the Default Text Strings in Drupal 8

How to Change the Default Text Strings in Drupal 8

Drupal 8.5 is available now, and we covered some of the key new features.

However, some smaller, but very useful features arrived with 8.5. For example, it’s now much easier to translate the default text.

A few years ago, we explained how to translate the default text in Drupal 7. The process was painful! Let me show you how much easier it is in Drupal 8.5.

First, go to the “Extend” tab and enable the “Interface Translation” and “Language” module:

enable multilingual modules

  • Next, go to “Configuration”, then “Languages”.
  • Click “Edit” next to “English” (or whatever your site’s default language is).
  • Select the box, “Enable interface translation to English”.
  • Click “Save language”.

enable interface translation

  • Next, go to “Configuration”, then “User interface translation”.
  • You can search for and translate language strings directly from this screen. In this example, I’m changing “Weight” to “Gravity”.
  • Click “Save translations”.

string translation

That’s really all there is to the process. It’s much, much easier than in Drupal 7. Here is my translated text live on the site:

translated string

Instructor

  • Steve is the founder of OSTraining. Originally from the UK, he now lives in Sarasota in the USA. Steve's work straddles the line between teaching and web development.

0 0 votes
Blog Rating
Subscribe
Notify of
5 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
amenokal

Great ! It’s working, waiting for a long time about a d8 version of String Overrides. Thank you !

belba

I wonder how to be able to translate other strings then only the labels. For example when a post is submitted, ‘submitted by’,
‘read more’, ‘3 comments’, ‘log in or register to post comments’, ‘log in’ …. manny help text …. do we have to rewrite this modules if we want to change anny of those?

Andrew Martin

Seems you can still also override through settings.php – 

$settings[‘locale_custom_strings_en’][”] = [
  ‘Content’ => ‘Stuff’,
];

Andrew Martin

Ugh…. forgot to wrap it in code tags…

[code]$settings[‘locale_custom_strings_en’][”] = [
  ‘Content’ => ‘Stuff’,
];[/code]

jsidigital

Thank you for that. It works.

However, we decided to uncheck that since we no longer need that option.

Problem now is that cron continuously keeps on searching for translation files for ALL modules ending in en.po and I am getting a lot of notice warning via drush everytime I run cron… Example:
[code]Translation file not found: https://ftp.drupal.org/files/translations/all/drupal/drupal-9.1.4.en.po.%5B/code%5D

It is doing this for all modules on every cron! Our watchdog is getting full of these logs.
It should not be searching for this since we unchecked the box you mentioned, so what is triggering cron to continuously look for these and how do I disable this from searching for all these english translation files which do not exist since drupal’s default language is English?

5
0
Would love your thoughts, please comment.x
()
x