How can we help?

If you are looking for support for our PokaTheme, this is the place!

Home Forums Child Themes support How to override language pack in child theme

Tagged: 

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #17138

    Hi there,

    I’m using PokaTheme V4.03, and I activated the Child Theme to avoid messing up wit the Parent theme.

    I’ve read https://pokatheme.com/topic/how-to-createedit-language-packs/

    I would like to change some translations in the child theme language pack rather that parent’s pack, following best practices to avoid touching to the parent theme.

    For example, I’m trying to change the “Play Now” button text in en_US language, for example to “Claim Now”.

    What I did is:
    1) create a languages folder in wp-content/themes/pokatheme_child/ because it doesn’t exist when the child theme is installed.
    2) I duplicated en_US.mo + en_US.po from wp-content/themes/pokatheme/languages/ to wp-content/themes/pokatheme_child/languages/
    3) I edited/saved the duplicated po/mo files before uploading them back to the server.

    But the changes are not showing up. I cleared the caches but no luck.

    Am doing it the right way? Could you please advise on the process?

    Thanks for the help!

    #17154

    I found a solution which I will share here in case it may help the community.

    What I had done in my initial post was OK, but for it to work it required to properly load the child theme translations, which I achieved by adding the following code to the child’s theme functions.php:

    add_action( ‘after_setup_theme’, function () {

    load_theme_textdomain( ‘poka’, get_stylesheet_directory() . ‘/languages’ );

    load_child_theme_textdomain( ‘poka’, get_stylesheet_directory() . ‘/languages’ );
    } );

    #17157
    admin
    Keymaster

    Hi!

    Thanks for your support!
    Another solution is to add the translations to ‘wp-content/languages/themes’ in order to keep translations outside the theme for better control.

    #17169

    Hey!

    thanks for your reply 🙂

    I was reading about this here https://developer.wordpress.org/themes/functionality/internationalization/#loading-translations

    I’m still weighing the pros & cons of one strategy vs the other, not sure which is the best, looking for the ease of maintenance over time, especially avoiding any problem when I update Pokatheme, or WordPress itself.

    #17200
    admin
    Keymaster

    Hi!

    From my experience the best solution is to keep your plugins/themes custom translations to wp-content/languages in order to avoid any loss from future updates.
    I believe this is also the official WordPress recommendation.

    #17201

    Hey!

    yes indeed, on the other hand, having everything under the child theme (wp-content/themes/pokatheme_child/) is also part of the usual recommendation in so far as it is supposed to be preserved customized files as well in case of parent theme update, isn’t it?

    Thanks for sharing your thoughts 🙂

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.