New Landing How can we help? Themeforest Theme Support Neighborhood Overriding translation with child theme

Viewing 12 posts - 1 through 12 (of 12 total)
  • #163137
    saturnerond
    Member
    Post count: 39

    Hi there,

    I’m trying to override the FR translation for the “Sold Out” product badge (on product image) but with no success. With the help of this previous thread and Google, here is what I tried so far (pure guess):

    My updated fr_FR.po (edited with PoEdit) and fr_FR.mo files are in a themes/neighborhood-child/languages folder.

    I then added the code below in my child theme functions.php file :

    <?php
    function my_child_theme_setup() {
        load_child_theme_textdomain( 'neighborhood-child', get_stylesheet_directory() . '/language' );
    }
    add_action( 'after_setup_theme', 'my_child_theme_setup' );
    ?>

    Unfortunately that doesn’t work. Could you please help spotting what I’m doing wrong?

    thank you,
    Ammie

    #163245
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    My colleague, Mr. Laranz will assist you shortly.
    Thanks
    Mohammad

    #163248
    saturnerond
    Member
    Post count: 39

    Thank you Mohammad.
    There is a typo in my code snippet above. The path is ‘/languages‘, with a S.
    Thanks.
    Ammie

    #163249
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    You most welcome. I am glad that you managed to resolve the issue.
    Thanks
    Mohammad

    #163252
    saturnerond
    Member
    Post count: 39

    Ooops,
    No, I didn’t managed to resolve the issue. There was just a typo in my first message that could have made Mr Laranz confused. But my code still doesn’t work, with or without typo.
    Sorry for the confusion.
    Ammie

    #163339
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Please live your website first and provide login detail to inspect the issue.
    Thanks
    Mohammad

    #163363
    laranz – SUPPORT
    Member
    Post count: 3186

    Hi,

    It should work, Try this two codex official information about child theme translation.

    1. http://codex.wordpress.org/Child_Themes#Internationalization
    2. https://codex.wordpress.org/Function_Reference/load_child_theme_textdomain

    Let us know,

    Thanks,
    laranz.

    #163455
    saturnerond
    Member
    Post count: 39

    Thank you Laranz,

    Well. I’m still unable to make that work. I attach a screenshot of my files name/path along with the content of my child theme functions.php file.

    So far I tried :
    – Change translation for “My account” –> Doesn’t work. Apparently the issue is not woocommerce-specific
    – Placed the add_action line before the function –> Doesn’t work
    – Placed my modified fr_FR.po and fr_FR.mo files in neighborhood-child root directory and used load_child_theme_textdomain( ‘neighborhood-child’ ); –> Still no success
    – Uploaded fresh WordPress 4.1.1 files (except wp-content and wp-config.php) and fresh Neighborhood 2.16 files –> Still doesn’t work
    – Checked my .po file is actually modified and my child theme activated : Yes!
    – Disabled all plugins except those required for the theme, cleaned database and deleted transients –> No change
    – I don’t know if this is expected or not but when I change define(‘WPLANG’, ‘fr_FR’); for define(‘WPLANG’, ‘en_US’); in the wp-config.php file, then the site frontend is still in French.
    – NB : I do not have WPML nor cache plugins installed.

    Do you see anything else I could try?

    Thanks a lot,
    Ammie

    Attachments:
    You must be logged in to view attached files.
    #163769
    matteth
    Member
    Post count: 3

    I just had the same problem, and made it work. It seems that the translations have use same textdomain as the parent theme. You need to translate both the “swiftframework” domain, and “woocommerce”.

    This works for me, loading the same translations twice …

    <?php
    function my_child_theme_setup() {
        load_child_theme_textdomain( 'swiftframework', get_stylesheet_directory() . '/languages' );
    load_child_theme_textdomain( 'woocommerce', get_stylesheet_directory() . '/languages' );
    }
    add_action( 'after_setup_theme', 'my_child_theme_setup' );
    ?>
    #163792
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Thanks @matteth
    You are totally right, we should designate the text domain we want to overide.
    In this case is swiftframework.

    -Rui

    #163816
    saturnerond
    Member
    Post count: 39

    Aaaaah… thank you sooooo much matteh for the clue 🙂

    In my case I had to do it the other way (using ‘swiftframework’ as textdomain keeps loading the parent theme .mo file).
    In case other users would have the same issue, I needed to override the translation for the “Out of Stock” badge :

    1 – In the child-theme functions.php file, I keep neighborhood-child (or whatever name) as textdomain :

    <?php
    function my_child_theme_setup() {
        load_child_theme_textdomain( 'neighborhood-child', get_stylesheet_directory() . '/languages' );
    }
    add_action( 'after_setup_theme', 'my_child_theme_setup' );
    ?>

    2 – In theme/child-theme/woocommerce/single-product/product-image.php, I edited the file to replace ‘swiftframework’ with ‘neighborhood-child’. For instance :

    // Line 24 - Change
    echo '<span class="out-of-stock-badge">' . __( 'Out of Stock', 'swiftframework' ) . '</span>';
    
    // To
    echo '<span class="out-of-stock-badge">' . __( 'Out of Stock', 'neighborhood-child' ) . '</span>';

    As overriding woocommerce .mo file specifically I did it the “woo” way and saved my custom .mo file in a wp-content/languages/woocommerce folder. As far as I can see, Neighborhood theme and Woocommerce do not translate the same strings.

    Ammie

    #163818
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Thanks for sharing the way you did it.
    -Rui

Viewing 12 posts - 1 through 12 (of 12 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register