0

I am working on functions.php in a child theme, Here I have a CPT and custom taxonomies for my project. The only thing I need to translate taxonomies and CPT right from the functions.php and be sure that after any updates of the core, theme or plugins it will still at its place (I mean translation).

What I did:

I tried numerous times __() function in many different ways and did what was in I18L L10N articles but it relates only to plugins and themes.

I created a .po and compiled it into .mo file for my child theme and for the parent theme. And once I have added the next to the functions.php:

    add_action( 'after_setup_theme', 'MyTheme-child_setup' );
function MyTheme-child_setup(){
    load_theme_textdomain( 'MyTheme-child', get_template_directory() . '/languages' );
}

and added .po and .mo (their names were ONLY a locale) into BOTH languages/ dirs of the parent and child themes it worked nicely. But... once the parent theme is updated everything is gone...

I used __() function like this then:

function my_cpt() {
$labels = array(
    'name'               => __( 'Node-A', 'MyTheme-child'),

But as I said - it worked ONLY when BOTH couples of .po and .mo were in /languages dirs of the parent AND the child themes.

I need a solution for capturing some textdomain, that will be used ONLY within my functions.php of the child theme and will NOT be affected by ANY updates either of the Core nor of the theme of plugins.

Any help is appreciated!

1

Added to the functions.php the next:

$pather = get_stylesheet_directory().'/languages';
load_child_theme_textdomain( 'Savia-child', $pather );

And then called it as:

__( 'text to translate', 'Savia-child');

In the child theme I have created a dir: /languages and put there po and mo files with the names: [locale].po/.mp like: ru_RU.po and ru_RU.mo.

That is.

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.