• Resolved nelero

    (@nelero)


    Hi,
    esc_html strings are not detected
    ex : <?php echo esc_html(‘Address’,’mydomain’); ?>
    So i can’t translate my theme completely.

    regards

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Marcin Kazmierski

    (@marcinkazmierski)

    Done!
    Please update to 3.2.6 version 😉

    Thread Starter nelero

    (@nelero)

    Thanks a lot !
    super reactive !

    Thread Starter nelero

    (@nelero)

    But my words is still not found 🙁
    I understood why :
    my theme is called marketor2021
    but the domain of the string is marketor

    <?php echo esc_html(‘Address’,’marketor’); ?>

    so there is no TTfp::marketor even after checking again via import/export translations

    Thread Starter nelero

    (@nelero)

    maybe you should use the “Text Domain” filled in the style.css
    To find it :
    wp_get_theme
    which returns an object data. So to identify a textdomain or to fallback to folder’s name if not written, we could use this code

    <?php 
    $theme_info = wp_get_theme();
    $text_domain = $theme_info->get('TextDomain');
    $text_domain = (empty($text_domain)?get_template():$text_domain);
    ?>
    Plugin Author Marcin Kazmierski

    (@marcinkazmierski)

    This is strange, I added code in my custom theme:

    
    <?php echo esc_html("Test1 esc_html"); ?>
    <?php echo esc_html("Test2 esc_html with domain", "marketor"); ?>
    <?php echo esc_html('Test3 esc_html with domain 2', 'marketor'); ?>
    

    And this is result:
    https://drive.google.com/file/d/1aWrOIqBPIT4-1j-zWK0LogtbSWrIHx3V/view?usp=sharing
    – give me more information please, because I cannot help you

    hint: this function “esc_html” has only one argument:
    https://developer.wordpress.org/reference/functions/esc_html/

    Thread Starter nelero

    (@nelero)

    as i explained,
    the name for texdomain picked by the plugin is the folder name, like returned by the function get_template()
    This name is listed in Languages > Export/Import translations in “Themes” section.

    But when the textdomain declared in the template is not the same as the folder’s template, it’s not found.
    So i gave you the code to find the right textdomain in this case.

    Ex :
    folder’s name : marketor2021

    Headers in style.css :

    /*
     Theme Name:   Marketor 2021
     Theme URI:    https://www.marketor.com/
     Description:  Marketor 2021
     Author:       Marketor INC
     Author URI:   https://www.marketor.com/
     Version:      1.0.0
     License:      GNU General Public License v2 or later
     License URI:  http://www.gnu.org/licenses/gpl-2.0.html
     Tags:         
     Text Domain:  marketor
    */

    As you see, the folder’s name is different for the textdomain used.
    And so the plugin doesn’t list marketor in Languages > Export/Import translations but only list marketor2021.
    So every string in theme files which are
    <?php echo esc_html("Test2 esc_html with domain", "marketor"); ?>
    will not be listed
    but
    <?php echo esc_html("Test2 esc_html with domain", "marketor2021"); ?>
    will be

    Plugin Author Marcin Kazmierski

    (@marcinkazmierski)

    ok, I added esc_html filter, please check 3.2.11 version 😉

    Regards,

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘add esc_html detection in theme’ is closed to new replies.