• No products in the cart.




Theme’s original text strings customization

Let’s say we are working on the WordPress theme customization for a writer’s website. It doesn’t matter if we are adding an additional language, or staying with a single original language. What is important, that the original English naming doesn’t quite work for our purpose.

For example, we’d like any mentioning of the theme’s custom post type “Portfolio” to appear as “Publication” at the front end of our writer’s website. Another example is a plugin Buddydrive, where we’d like the name “Drive” to appear as “Files“.

Do we have to search for the strings in the php and js code, make changes to them, and to repeat it over and over after each theme update? No, we can utilize the translation system in order to change the text strings. It may look strange, as there is no translation here. We only substitute one English words with others.

Usually the localization of the English language is not defined in the en.po file. That’s why, to make text strings customization working, we need to add an important definition to the WordPress configuration file, and the original translation file.

If we’re customizing the theme for the American English (en_US), then the entire procedure will look as following.

  1. Define the original language localization for WordPress
    Add the string to wp-config.php
    define ('WPLANG', 'en_US');
  2. Rename the original translation files if needed
    Check your theme or plugin language folders and rename the original language file according to the localization template (en_US in our case), if it has a simplified name en.po.
    As it was mentioned in the previous articles of this series, text_domain is defined for each plugin, or theme. Most of the time it is the name of the theme or plugin folder.
  3. Define the original language localization in translation files
    There are two ways to make the definition:
    a) Open the renamed en_US.po file in text editor and change, or add (if it’s absent) the language string in the header
    "Language: en_US\n"
    b) Open the en_US.po  in poEdit, go to the Catalog -> Properties menu and select “English (United States)” in language field, as shown below. Save your .po file.
Poedit language settings
Poedit language settings


Now to change the original theme/plugin text strings you need to add translations (substitution English strings) for those strings in your en_US.po file. Use the poEdit Find tool (Edit -> Find) to make the process faster.

 All articles from this series

  1. Introduction to the structure of the WordPress translation.
  2. How to translate Wodpress themes and plugins.
  3. Theme’s original text strings customization.
  4. How to translate child themes.
  5. How to handle translations with plugins and theme updates.
  6. Adding a second language to a WordPress website.
  7. Adding translation support to WordPress themes and plugins.

As usually, I’ll be glad to answer your questions, or provide more clarification on the topic of this article:

1 comment

    Leave a Reply

    © Isigma Photo. All rights reserved



    FACEBOOKGOOGLECreate an Account