• there’s a website on custom theme and the Polylang plugin. It was good when I used for couple months. While changing the language it translated such code

    <?php _e('Hello!','themedomain'); ?>

    Then something went wrong and it stopped translating. .mo and .po files didn’t change, code too. But now it stopped to translate expressions.

    Polylang 2.0.4, WordPress 4.6.1

    Loading text domain:

    add_action( 'after_setup_theme', 'mytheme_setup' );
    if ( ! function_exists( 'mytheme_setup' ) ):
    function mytheme_setup() {
        add_editor_style();
        add_theme_support( 'post-thumbnails' );
        add_theme_support( 'automatic-feed-links' );
        $path = get_template_directory() . '/languages';
        //$result = load_theme_textdomain('themedomain', $path );
        //if ( $result )
         //return;
        //$locale = apply_filters( 'theme_locale', get_locale(), 'themedomain' );
        //die( "Could not find $path/$locale.mo." );
        load_theme_textdomain('themedomain', $path );
        //if ( is_readable( "$path/$locale.mo")) { echo "+"; } else { echo "-"; };  
    }
    endif;

    If I uncomment this

    //$result = load_theme_textdomain('themedomain', $path );
    //if ( $result )
     //return;
    //$locale = apply_filters( 'theme_locale', get_locale(), 'themedomain' );
    //die( "Could not find $path/$locale.mo." );

    it shows “Could not find /the/full/path/ru_RU.mo”, however another language is chosen.

    If I uncomment this

    //if ( is_readable( "$path/$locale.mo")) { echo "+"; } else { echo "-"; };

    it shows –

    Files permissions are 666, ‘languages’ directory is 777.

Viewing 1 replies (of 1 total)
  • I had a similar problem, that .mo files did not found. I had specified the text domain in the style.css:

    Text Domain: theme-name
    Domain Path: /languages

    and in the functions.php I used in the theme setup function ( after_setup_theme ) only:
    load_theme_textdomain( ‘theme-name’ );

    After I spezified the explicit path to the translations, it works and Polylang found my translation files ( .mo / .po ):

    load_theme_textdomain( 'theme-name', get_template_directory() . '/languages' );

    • This reply was modified 7 years, 5 months ago by felix76.
Viewing 1 replies (of 1 total)
  • The topic ‘An issue with Polylang and theme translation’ is closed to new replies.