How to add new translations to child theme?

Updated: March 2, 2017

How we can add new words and create translations for child theme?

You can follow these steps:

  • Create child theme and copy your file (with my example it is header.php) to child theme
  • Inside header.php file (change to your file) I added new string to 98 line:  <h3>{__ ‘my new string’}</h3>
  • Created new directory2-child.pot file inside wp-content/themes/directory2-child/ait-theme/languages/directory2-child.pot
    # Copyright (C) 2017 AitThemes.club
    # This file is distributed under the GNU General Public License.
    
    msgid ""
    
    msgstr ""
    "Project-Id-Version: Directory+\n"
    "Report-Msgid-Bugs-To: https://system.ait-themes.club/support/\n"
    "POT-Creation-Date: 2017-01-12 14:04:47+00:00\n"
    "MIME-Version: 1.0\n"
    "Content-Type: text/plain; charset=UTF-8\n"
    "Content-Transfer-Encoding: 8bit\n"
    "PO-Revision-Date: 2017-MO-DA HO:MI+ZONE\n"
    
    "Language-Team: LANGUAGE <LL@li.org>\n"
    
    #: /header.php:98
    
    msgid "my new string"
    
    msgstr ""
  • With poedit editor I generated wp-content/themes/directory2-child/ait-theme/languages/en_US.po
    and wp-content/themes/directory2-child/ait-theme/languages/en_US.mo
    # Copyright (C) 2017 AitThemes.club
    # This file is distributed under the GNU General Public License.
    
    msgid ""
    
    msgstr ""
    "Project-Id-Version: Directory+\n"
    "Report-Msgid-Bugs-To: https://system.ait-themes.club/support/\n"
    "POT-Creation-Date: 2017-03-01 17:04+0100\n"
    "MIME-Version: 1.0\n"
    "Content-Type: text/plain; charset=UTF-8\n"
    "Content-Transfer-Encoding: 8bit\n"
    "PO-Revision-Date: 2017-03-01 17:05+0100\n"
    "Language-Team: \n"
    "X-Generator: Poedit 1.8.3\n"
    "Last-Translator: \n"
    "Plural-Forms: nplurals=2; plural=(n != 1);\n"
    "Language: en_US\n"
    
    #: /header.php:98
    
    msgid "my new string"
    
    msgstr "How are you"
  • Also I generated other languages
  • With ait-languages plugin I have created en_US language and also de_DE
    If directory+ was loaded in header appeared my new strings.