How to Translate or Change Text in the Theme or Plugins

How to Translate or Change Text in the Theme or Plugins

There are two main ways to translate or change specific text (strings) in the Listify theme or its associated plugins:


We highly recommend using the Loco Translate plugin. It provides a visual interface directly within your WordPress dashboard for translating theme and plugin strings using the built-in PO/MO files.

Steps:

  1. Install and activate the Loco Translate plugin.
  2. Navigate to Loco Translate ▸ Themes or Plugins.
  3. Select Listify (or any plugin you want to translate).
  4. Choose your target language or add a new one.
  5. Search for strings and edit translations directly.

Tip: To prevent losing your translations during updates, always store them in the System or Custom folder rather than the default author folder.


Option 2: Modify Strings Using Code

If you prefer to override or customize text directly in code without affecting translation files, you can do so using WordPress’s gettext filter. This is useful for simple text replacements.

Add the following code to your child theme’s functions.php file:

“`php
// Custom string replacement
add_filter( ‘gettext’, function ( $translated_text ) {

// Define replacements here
$custom_strings = array(
‘Describe what you sell’ => ‘Translate/Change’,
‘Vendor Name’ => ‘Nom Du Vendeur’,
‘This is the name that customers see when purchasing your products. Please choose carefully.’ => ‘C\’est le nom que les clients voient lors de l\’achat de vos produits. Veuillez choisir soigneusement.’,
‘Sign Up’ => ‘Inscrivez-vous’,
‘Read More’ => ‘Lire Plus’,
);

return str_ireplace( array_keys( $custom_strings ), $custom_strings, $translated_text );

}, 20 );

Was this article helpful?

Related Articles