Codeless
  • Support Home
  • Themes
  • Support
  • WordPress Tutorials
    • How to Start a Blog
    • Best Website Builders
    • Best Small Business Hosting
    • Email Marketing Services
    • Cheap WordPress Hosting
  • Video Tutorials

Community Forums

Add custom locale for child theme?

    • 7 years, 3 months ago cravingvapor
      Participant

      Expired

      I’m trying to add a custom locale file for our child theme to replace some clothing-specific text in June (we’re not a clothing store) but for some reason the hook isn’t working.

      Here’s our june-child/lang/june-child.pot file:

      #: woocommerce/single-product/related.php:34
      msgid "Similar Styles"
      msgstr "Similar Products"

      And our june-child/functions.php file:

      <?php
      
      function child_enqueue_scripts() {
              wp_register_style( 'childtheme_style', get_template_directory_uri() . '/style.css'  );
              wp_enqueue_style( 'childtheme_style' );
      }
      
      add_action( 'wp_enqueue_scripts', 'child_enqueue_scripts');
      
      function load_locale() {
              load_child_theme_textdomain( 'june-child', get_template_directory() . '/lang' );
      }
      
      add_action( 'after_setup_theme', 'load_locale' );
      
      ?>

      Any advice?

    • 7 years, 3 months ago Mirela
      Participant

      Hello,

      Please go to file functions.php in parent theme, find these lines:

      /**
       * Setup Language Directory and theme text domain
       * 
       * @since 1.0.0
       */
      function codeless_language_setup() {
          $lang_dir = get_template_directory() . '/lang';
          load_theme_textdomain('june', $lang_dir);
      } 

      where lang folder is called and replace get_template_directory function with get_stylesheet_directory. So it will give priority to the child theme file instead of the parent.

      Best regards!

      • 7 years, 3 months ago cravingvapor
        Participant

        Expired

        Editing the parent theme will have to repeated whenever we update it, this should be possible through the child theme I’m just not sure why the hook isn’t working.

    • 7 years, 3 months ago Mirela
      Participant

      Hello,

      The strings in your child theme pot file are just changed, not translated to another language. What language do you have selected for the site to use?
      If you want, you can send us some valid wp credentials in a private reply. So we can give it a closer look and help you configure what you want.
      Let us know.

      Best regards!

    • 7 years, 3 months ago cravingvapor
      Participant

      Expired

      The child theme isn’t a language translation, just using the language file to update some strings to be more relevant to our products. “Similar Styles” wouldn’t make sense with our product catalog (we don’t sell clothing primarily), that’s why I’m changing it to “Similar Products”. There are a few strings like this that I need to change.

    • 7 years, 3 months ago Mirela
      Participant

      Hello,

      I understand. Did you generate the new .po file after making changes to the .pot file? Please follow the below steps:
      1-Generate the new .po file after editing the string you want to change;
      screenshot: https://postimg.org/image/idmmtmfk5/
      https://postimg.org/image/59h2gufrp/

      2-Add this line into your wp-config.php file: define ('WPLANG', 'en');
      screenshot: https://postimg.org/image/pgui9a305/
      3-Go to dashboard > Settings > General > Site language, select the new file as your site’s language;
      screenshot: https://postimg.org/image/3ufhsbwqt/
      *Your site’s current configuration screenshot: https://postimg.org/image/rwwbn8nol/
      the new file is not present, or chosen.

      This is the result after using the new .po file: https://postimg.org/image/ry69gokdh/
      Please try this out and let us know.

      Best regards!

Viewing 4 reply threads

You must be logged in to reply to this topic.

Login

Log In
Register

Renew Support

  • Renew Specular Support
  • Renew Tower Support
  • Renew Folie Support
  • Renew Handel Support
  • Renew June Support
  • Renew Picante Support
  • Renew Thype Support
  • Renew Regn Support

Search Forums

Forums

  • Bygge – Construction Theme
  • Converta – Software Theme
  • Folie – The WordPress Website Builder
  • Handel – Responsive Multi-Purpose Business Theme
  • June WooCommerce WordPress Theme
  • Livecast – Podcast Theme
  • Picante – Restaurant & Food WordPress Theme
  • Regn | Agency & Business WordPress Theme
  • Remake – Minimal Portfolio & Agency Theme
  • Specular – Multi-Purpose WordPress Theme
  • Suggest us Features
  • Tower – Business-Driven Multipurpose WP Theme
  • Vibrance – Photography Theme

Site Links

  • Support Policy
  • Specular Support Forum
  • Video Tutorials
  • Knowledge Base
  • Guides and Reviews

Useful Articles

  • Build a Website
  • Web Design & Development
  • Hosting
  • WordPress

Login

Log In
Register Lost Password