Viewing 16 posts - 1 through 16 (of 16 total)
  • Author
    Posts
  • #1120309

    Hi Enfold Team,

    we are using Enfold for a lot of projects (at least over 20) and are having trouble translating our child themes.

    We tried to fix this issue by ourselves for quite some time now, but couldn’t succeed.

    Our Setup:

    Main Issues:

    • Translations for our text domain are being loaded correctly
    • Translations for the Enfold parent theme are not being loaded (e.g. 404 page, enfold widgets, etc)
    • When updating poedit, all enfold translations are being removed from the files, just leaving the child theme translations. Could this be the reason?

    Code:
    functions.php

    add_action( 'after_setup_theme', 'avia_lang_setup' );
    function avia_lang_setup() {
    	$lang = get_stylesheet_directory() . '/lang';
    	load_child_theme_textdomain( 'mytextdomain', $lang );
    }

    style.css

    /*
    Theme Name: mytheme
    Description: A <a href='http://codex.wordpress.org/Child_Themes'>Child Theme</a> for ClientXYZ.
    Version: 1.0
    Template: enfold
    Text Domain: mytextdomain
    Domain Path: /lang
    */

    Notes:
    As documented here https://developer.wordpress.org/themes/functionality/internationalization/

    The text domain name must use dashes and not underscores and be lowercase.

    -> We made sure not to use underscores in our text domains (as opposed to the stackexchange question)
    -> BUT the Enfold text domain is “avia_framework” (could this be an / the issue?)

    #1121098

    Hey Chris,

    Thank you for using Enfold.

    Are you trying to use your own translation in the child theme? Please remove the current code in the functions.php file and replace it with the following snippet.

    function overwrite_language_file_child_theme() {
        $lang = get_stylesheet_directory().'/lang';
        return $lang;
    }
    add_filter('ava_theme_textdomain_path', 'overwrite_language_file_child_theme');

    Which texts in particular are you trying to translate?

    Best regards,
    Ismael

    #1121165

    Hi Ismael,

    Thanks for your help, but the code you provided unfortunately couldn’t solve the problem. Actually after embedding your code no translation was loaded at all.

    There are a lot of strings we’d like to translate like
    – “Share this entry”
    – “You might also like”
    – “Leave a reply”
    – Placeholder “Search” in the search bar
    – and so on.

    Basically we can say that only child theme strings which are comprised in the child theme po/mo files are being translated, while none of the parent theme strings are.

    Looking forward to your reply.

    Thanks a lot in advance!

    #1121920

    Hi,

    Thank you for the update.

    Did you put the language files (.po|.mo) inside the “lang” folder of the child theme? The purpose of the filter above is to redirect the theme text domain directory to the child theme’s “lang” folder.

    You can also use this plugin.

    // https://wordpress.org/plugins/loco-translate/

    Best regards,
    Ismael

    #1121921

    Hi Ismael,

    yes, we have the po/mo files in the child theme /lang/ folder.

    As we have really a lot of enfold installs in this configuration we’d love not to use a plugin.

    If you need any server access please just let me know.

    Thanks a lot again in advance!

    #1122049

    Hi,

    Thank you for the update.

    Yes, please post the WP and FTP details in the private field. Can you provide the corresponding translations for the texts so that I can add them?

    Best regards,
    Ismael

    #1122164

    Thanks for your reply Ismael!

    Please find the login data attached.

    #1122626

    Hi,

    Thank you for the update.

    We disabled the “avia_lang_setup” function in your child theme and reactivated the “avf_overwrite_language_file_child_theme” function. (see private field)

    Best regards,
    Ismael

    #1122721

    Hi Ismael,

    Thanks a lot for your help!

    We have a 1:1 copy of the environment you just made the changes.

    When just activating the “avf_overwrite_language_file_child_theme” there we still have the same issue.

    Did you do anything else (no matter how unimportant) ???

    Thanks again a lot in advance!

    #1123018

    Hi,

    Did you update the language files? Sorry, I forgot to mention that I also updated the language files in the “lang” folder using the latest version from the parent theme.

    Thank you for the update.

    Best regards,
    Ismael

    #1123158

    Hi Ismael,

    Thanks a lot for your help.

    Updating the language files might be part of the solution. Could you explain to me in detail how you updated them?

    We use Poedit and it automatically scans our child theme for new strings matching our text domain.

    When doing so it also automatically removes all strings which have a different text domain from the po/mo files, which means all the strings with “avia_framework” as text domain (enfold strings) are being removed.

    We always thought that this step is how it’s supposed to be, but now we get the feeling that this might be part of the problem.

    Is there a way to manually add the strings to our language files?

    #1123820

    Hi,

    We just copied the latest version from the parent theme and place it in the child theme’s lang folder. You need to use the “avia_framework” text domain because the strings that you’re trying to translate belongs to it. The underscores in the text domain name may not be in accordance with the I18n standards but it’s still going to work. If you want to use POEdit, try to manually open the PO file in the lang folder, translate the strings, then compile the MO file.

    Best regards,
    Ismael

    #1127657

    Hey Ismael,

    Thanks for your latest reply!

    We just realized that this code here works for us:

    add_action( 'after_setup_theme', 'avia_lang_setup' );
    function avia_lang_setup() {
    	$lang = apply_filters('enfold', get_template_directory()  . '/lang');
    	load_theme_textdomain('avia_framework', $lang);
    	load_child_theme_textdomain( 'child-theme-text-domain', get_stylesheet_directory() . '/lang' );
    }
    #1127660

    Hi,

    Great! Did you need additional help or shall we close this topic?

    Best regards,
    Jordan Shannon

    #1127678

    Hi Jordan,

    all good now, you can close the topic.

    Thanks!

    #1127681

    Hi,

    If you need additional help, please let us know here in the forums.

    Best regards,
    Jordan Shannon

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

The topic ‘Translation with Poedit and Child Theme’ is closed to new replies.