1

I donwloaded and applied a theme to my WordPress 4.7.2 installation.

The site's locale specified in the admin settings is it_IT and the theme was not translated in this language so I'm trying to create a translation for the custom strings the theme uses.

So what I did was:

  • Opened the /wp-content/themes/thf/languages/thf.pot file (thf being the theme's name) with POEdit
  • Created a new it_IT translation and translated all the strings
  • Saved the project. /wp-content/themes/thf/languages/it_IT.po and /wp-content/themes/thf/languages/it_IT.mo files were created
  • Edited the functions.php adding the following.

.

function thf_setup() {
    load_theme_textdomain( 'thf', get_template_directory() . '/languages' );
}

add_action( 'after_setup_theme', 'thf_setup' );

But the strings won't translate. Looks like I don't need to define WP_LANG in config.php since I'm on WordPress 4.7.2 so I didn't edit that.

I also looked at other similar questions but they all point to either load_theme_textdomain, which I added, or WP_LANG, which I don't need.

Am I missing something else? Thanks in advance for your attention.

  • double check your theme textdomain name and the names supplied to gettext helper functions. – Anwer AR Feb 13 '17 at 20:15
1

The problem was more trivial then expected.

The function thf_setup() was already defined and hooked in the theme's functions.php so I just added the load_theme_textdomain call to that function instead of declaring a new one (which would also be duplicated).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.