[Support request] I can’t translate my site via .po and .mo

Home Forums Support [Support request] I can’t translate my site via .po and .mo

Home Forums Support I can’t translate my site via .po and .mo

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1635295
    Luca

    Hi,
    I’m using a multisite with multilingualpress. I’m trying to translate one or two words in a theme, but I’m failing.The theme is Blankslate (https://it.wordpress.org/themes/blankslate/). It’s a blank theme which I personalized a lot via child theme (in themes/blankslate-child).
    This is the head of the style.css

    /*
    Theme Name:   Child di BlankSlate.
    Description:  mio
    Text Domain:  blankslate-child
    Domain Path: /languages
    Author URI:  https://www.lgwebdesign.it
    Template:  blankslate
    Version:  1.1
    License:  GNU General Public License v2 or later
    License URI: https://www.gnu.org/licenses/gpl-2.0.html                 
    */

    I’m trying to translate the file archive-product.php, regarding WooCommerce. The files is inside /wp-content/themes/blankslate-child/woocommerce
    I’m trying to modify this page https://chiaragini.it/negozio/, specifically translate in Italian the “category” and “products” titles.

    <?php
    /**
     * The Template for displaying product archives, including the main shop page which is a post type archive
     *
     * This template can be overridden by copying it to yourtheme/woocommerce/archive-product.php.
     *
     * HOWEVER, on occasion WooCommerce will need to update template files and you
     * (the theme developer) will need to copy the new files to your theme to
     * maintain compatibility. We try to do this as little as possible, but it does
     * happen. When this occurs the version of the template file will be bumped and
     * the readme will list any important changes.
     *
     * u/see https://docs.woocommerce.com/document/template-structure/
     * u/package WooCommerce\Templates
     * u/version 3.4.0
     */
    
    defined( 'ABSPATH' ) || exit;
    
    get_header( 'shop' );
    
    /**
     * Hook: woocommerce_before_main_content.
     *
     * u/hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
     * u/hooked woocommerce_breadcrumb - 20
     * u/hooked WC_Structured_Data::generate_website_data() - 30
     */
    do_action( 'woocommerce_before_main_content' );
    
    ?>
    <header class="woocommerce-products-header">
    	<?php if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?>
    		<h1 class="woocommerce-products-header__title page-title"><?php woocommerce_page_title(); ?></h1>
    	<?php endif; ?>
    
    	<?php
    	/**
    	 * Hook: woocommerce_archive_description.
    	 *
    	 * u/hooked woocommerce_taxonomy_archive_description - 10
    	 * u/hooked woocommerce_product_archive_description - 10
    	 */
    	do_action( 'woocommerce_archive_description' );
    	?>
    </header>
    <?php
    
    $x = woocommerce_maybe_show_product_subcategories();
    $y = __('Category', 'blankslate-child');
    //$y = 'Categorie';
        //seguono nostre categorie
        if(strlen(trim($x)) != 0)
        echo "<h2>{$y}</h2><ul class=\"products columns-4\">{$x}</ul>";
        //fine categorie
    ?>
    <h2 id="h2prodotti"><? _e('Products', 'blankslate-child') ?></h2>
    <?php
    if ( woocommerce_product_loop() ) {
    	/**
    	 * Hook: woocommerce_before_shop_loop.
    	 *
    	 * u/hooked woocommerce_output_all_notices - 10
    	 * u/hooked woocommerce_result_count - 20
    	 * u/hooked woocommerce_catalog_ordering - 30
    	 */
        do_action( 'woocommerce_before_shop_loop' );
        remove_filter( 'woocommerce_product_loop_start','woocommerce_maybe_show_product_subcategories' );
    	woocommerce_product_loop_start();
    	if ( wc_get_loop_prop( 'total' ) ) {
    		while ( have_posts() ) {
    			the_post();
    
    			/**
    			 * Hook: woocommerce_shop_loop.
    			 */
    			do_action( 'woocommerce_shop_loop' );
    			wc_get_template_part( 'content', 'product' );
    		}
    	}
    	woocommerce_product_loop_end();
    
    	/**
    	 * Hook: woocommerce_after_shop_loop.
    	 *
    	 * u/hooked woocommerce_pagination - 10
    	 */
    	do_action( 'woocommerce_after_shop_loop' );
    } else {
    	/**
    	 * Hook: woocommerce_no_products_found.
    	 *
    	 * u/hooked wc_no_products_found - 10
    	 */
    	do_action( 'woocommerce_no_products_found' );
    }
    
    /**
     * Hook: woocommerce_after_main_content.
     *
     * u/hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
     */
    do_action( 'woocommerce_after_main_content' );
    
    /**
     * Hook: woocommerce_sidebar.
     *
     * u/hooked woocommerce_get_sidebar - 10
     */
    do_action( 'woocommerce_sidebar' );
    
    get_footer( 'shop' );

    This is my child theme functions.php

    <?php
    function mytheme_add_woocommerce_support() {
    	add_theme_support( 'woocommerce' );
    }
    add_action( 'after_setup_theme', 'mytheme_add_woocommerce_support' );
    
    // supporto multilingua
    function child_theme_slug_setup() {
        load_child_theme_textdomain( 'parent-theme-slug', get_stylesheet_directory() . '/languages' );
    }
    add_action( 'after_setup_theme', 'child_theme_slug_setup' );
    
    //add_action( 'after_setup_theme', 'blankslate_child_setup' );
    //function blankslate_child_setup(){
    	
    //	$x = load_child_theme_textdomain('blankslate', get_stylesheet_directory(). '/languages');
    // }
    /* fine commento codice Gigli */
    /*
    function debug_textdomain(){
    	//$locale = apply_filters( 'theme_locale', determine_locale(), $domain );
    	
    	//$locale = get_locale();
        //$locale_file = get_template_directory() . "/languages/$locale.php";
    	//echo "<br>";
    	//echo $locale;
    	//echo "-";
    	//echo $locale_file;
    }
    add_action('load_textdomain','debug_textdomain');
    */
    // menus
    function register_my_menus() {
      register_nav_menus(
        array(
          'menu-lingue' => __( 'Menu lingue' )
         )
       );
     }
     add_action( 'init', 'register_my_menus' );
    
    // deregister contact form 7
    add_action( 'wp_print_styles', 'wps_deregister_styles', 100 );
    function wps_deregister_styles() {
        wp_deregister_style( 'contact-form-7' );
    }
    
    ?>
    

    This is the main theme functions.php

    <?php
    add_action( 'after_setup_theme', 'blankslate_setup' );
    function blankslate_setup() {
    load_theme_textdomain( 'blankslate', get_template_directory() . '/languages' );
    add_theme_support( 'title-tag' );
    add_theme_support( 'automatic-feed-links' );
    add_theme_support( 'post-thumbnails' );
    add_theme_support( 'html5', array( 'search-form' ) );
    global $content_width;
    if ( ! isset( $content_width ) ) { $content_width = 1920; }
    register_nav_menus( array( 'main-menu' => esc_html__( 'Main Menu', 'blankslate' ) ) );
    }
    add_action( 'wp_enqueue_scripts', 'blankslate_load_scripts' );
    function blankslate_load_scripts() {
    wp_enqueue_style( 'blankslate-style', get_stylesheet_uri() );
    wp_enqueue_script( 'jquery' );
    }
    add_action( 'wp_footer', 'blankslate_footer_scripts' );
    function blankslate_footer_scripts() {
    ?>
    <script>
    jQuery(document).ready(function ($) {
    var deviceAgent = navigator.userAgent.toLowerCase();
    if (deviceAgent.match(/(iphone|ipod|ipad)/)) {
    $("html").addClass("ios");
    $("html").addClass("mobile");
    }
    if (navigator.userAgent.search("MSIE") >= 0) {
    $("html").addClass("ie");
    }
    else if (navigator.userAgent.search("Chrome") >= 0) {
    $("html").addClass("chrome");
    }
    else if (navigator.userAgent.search("Firefox") >= 0) {
    $("html").addClass("firefox");
    }
    else if (navigator.userAgent.search("Safari") >= 0 && navigator.userAgent.search("Chrome") < 0) {
    $("html").addClass("safari");
    }
    else if (navigator.userAgent.search("Opera") >= 0) {
    $("html").addClass("opera");
    }
    });
    </script>
    <?php
    }
    add_filter( 'document_title_separator', 'blankslate_document_title_separator' );
    function blankslate_document_title_separator( $sep ) {
    $sep = '|';
    return $sep;
    }
    add_filter( 'the_title', 'blankslate_title' );
    function blankslate_title( $title ) {
    if ( $title == '' ) {
    return '...';
    } else {
    return $title;
    }
    }
    add_filter( 'the_content_more_link', 'blankslate_read_more_link' );
    function blankslate_read_more_link() {
    if ( ! is_admin() ) {
    return ' <a href="' . esc_url( get_permalink() ) . '" class="more-link">...</a>';
    }
    }
    add_filter( 'excerpt_more', 'blankslate_excerpt_read_more_link' );
    function blankslate_excerpt_read_more_link( $more ) {
    if ( ! is_admin() ) {
    global $post;
    return ' <a href="' . esc_url( get_permalink( $post->ID ) ) . '" class="more-link">...</a>';
    }
    }
    add_filter( 'intermediate_image_sizes_advanced', 'blankslate_image_insert_override' );
    function blankslate_image_insert_override( $sizes ) {
    unset( $sizes['medium_large'] );
    return $sizes;
    }
    add_action( 'widgets_init', 'blankslate_widgets_init' );
    function blankslate_widgets_init() {
    register_sidebar( array(
    'name' => esc_html__( 'Sidebar Widget Area', 'blankslate' ),
    'id' => 'primary-widget-area',
    'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    'after_widget' => '</li>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
    ) );
    }
    add_action( 'wp_head', 'blankslate_pingback_header' );
    function blankslate_pingback_header() {
    if ( is_singular() && pings_open() ) {
    printf( '<link rel="pingback" href="%s" />' . "\n", esc_url( get_bloginfo( 'pingback_url' ) ) );
    }
    }
    add_action( 'comment_form_before', 'blankslate_enqueue_comment_reply_script' );
    function blankslate_enqueue_comment_reply_script() {
    if ( get_option( 'thread_comments' ) ) {
    wp_enqueue_script( 'comment-reply' );
    }
    }
    function blankslate_custom_pings( $comment ) {
    ?>
    <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>"><?php echo comment_author_link(); ?></li>
    <?php
    }
    add_filter( 'get_comments_number', 'blankslate_comment_count', 0 );
    function blankslate_comment_count( $count ) {
    if ( ! is_admin() ) {
    global $id;
    $get_comments = get_comments( 'status=approve&post_id=' . $id );
    $comments_by_type = separate_comments( $get_comments );
    return count( $comments_by_type['comment'] );
    } else {
    return $count;
    }
    }

    I used poedit to create .po and .mo, but the translation is not applied. Any clues?

    #1635970
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    This doesn’t seem to be a GeneratePress-related question – can you confirm?

    We aren’t able to help with other themes in this forum, unfortunately.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.