-
-
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?
-
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 withget_stylesheet_directory
. So it will give priority to the child theme file instead of the parent.Best regards!
-
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.
-
-
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!
-
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.
-
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!
-
You must be logged in to reply to this topic.