How do I override a parent theme’s language files with a child theme?

I have a parent theme and a child theme, I would like to override the spanish .mo and .po files in the parent theme (or add them if they are not present in the parent theme) with the es_ES ones in my child theme. I added the folder with the modified mo and po files in the child theme with the same folder name as in the parent theme but this is not working. How can I come about this?
Thanks!

Related posts

Leave a Reply

2 comments

  1. you may use this below code for your problem:
    
      [1]: https://i.stack.imgur.com/5aX1D.png
    

    or use below code:

    add_action( 'after_setup_theme', function () 
    {
    
        load_theme_textdomain( 'your parent theme name', get_stylesheet_directory() . '/languages/' );
    
        load_child_theme_textdomain( 'your child theme name', get_stylesheet_directory() . '/languages' );
    } );
    
    
  2. If you want to change more than just the stylesheet, your child theme can override any file in the parent theme: simply include a file of the same name in the child theme directory, and it will override the equivalent file in the parent theme directory when your site loads. For instance, if you want to change the PHP code for the site header, you can include a header.php in your child theme’s directory, and that file will be used instead of the parent theme’s header.php.

    You can also include files in the child theme that are not included in the parent theme. For instance, you might want to create a more specific template than is found in your parent theme, such as a template for a specific page or category archive. See the Template Hierarchy for more information about how WordPress decides what template to use.