2

I made a custom theme named testTheme having these files:

The files of my theme

And I wanted to put some translation on it therefore I created the required .po and .mo files for greek language via poedit as seen in the following image:

Theme files

But I cannot make it load the custom translations I created via poedit. Do you have any idea how I will load them?

Edit 1

The functions.php as asked:

<?php


if(!function_exists('loadThemerequirements')):

function loadThemerequirements()
{
    load_theme_textdomain( 'testTheme', get_template_directory() . '/languages' );
}

endif;

add_action( 'after_setup_theme', 'loadThemerequirements' );

Update1

The translations files were moved and renamed like that:

New translation files

Still Same result.

Edit 2:

This is not a child theme but a from-scratch made one.

Edit 3:

I tried renaming the .po and .mo files as el_GR.po and el_GR.mo still same result. I also tried to rename them in to testTheme/el_GR.po and testTheme/el_GR.mo without any success.

Update 2

The theme is in this git repository: https://github.com/pc-magas/testTheme

Edit 1

I changed my 404 page (that has some text to be translated into greek) like that:

<?php
get_header();
?>
<div class="fullpage_center">
    <div>
        <h1>404</h1>
        <p><?php _e('The requested page does not exist.','testTheme');?></p>
    </div>
</div>
<?php
    wp_reset_query(); //resetting the page query
    get_footer();
?>

A sample of my page and the translated text is:

404 page with text that needs to be translated

As you can see still no result.

2
  • show us the code you use in functions.php to load the translations
    – mmm
    Mar 25, 2017 at 22:19
  • 1. edit your translate file name from testTheme-el to testTheme-el_GR 2. set your textdomain in _e or __ functions
    – MahdiY
    Mar 26, 2017 at 13:17

2 Answers 2

2
  1. Change your translate file name to el_GR.po and el_GR.mo:

    el_GR.po in: testTheme\languages\el.po
    el_GR.mo in: testTheme\languages\el.mo
    
  2. In 404.php file for print text you should write code like this (add textdomain):

    <?php _e('The requested page does not exist.', 'testTheme'); ?>
    

Second parameter is textdomain.

7
  • Do I need to reinstall my theme? I develop it straight through a wordpress installation without reinstalling or re-enabling. Mar 26, 2017 at 17:44
  • 1
    No, just add textdomain to your strings
    – MahdiY
    Mar 26, 2017 at 17:46
  • Also do I need to rename my theme's folder into testTheme-master currently is into folder testTheme Mar 26, 2017 at 17:54
  • 1
    excuse me. template folder name is mistake! folder name not need rename.
    – MahdiY
    Mar 26, 2017 at 17:58
  • But still I cannot get the translated text from the 404 page I get the English one. Mar 26, 2017 at 18:10
1

If you have a child theme, in your function.php you have to change get_template_directory() by get_stylesheet_directory()

3
  • 1
    I do not have a child theme. It is a pure-made theme from scratch. Mar 26, 2017 at 13:37
  • 2
    Do you see any parent theme in this picture?
    – MahdiY
    Mar 26, 2017 at 13:39
  • Also I tried it and still no result. Mar 26, 2017 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.