how can i auto-register strings with wpml in wordpress?

i am trying to auto register string in wordpress, but for some reason it doesn’t work

it works when i call in the code of the theme:

Read More
esc_html_e('mytext','mythemename');

and then do

WPML->theme and plugins localization->strings in the theme->scan the theme for strings 

then mytext appears in strings list for translation

but if i try instead to enable:

 wpml->string translation->auto register strings for translation->auto-register strings always->apply

and in the code run, f.ex.:

$myvar='mytext';
esc_html_e($myvar,'mythemename');

then, of course, i go to wp page where string appears, but nothing happens, string doesn’t get added to theme strings list

does anybody know if i am doing something wrong?

Related posts

Leave a Reply

1 comment

  1. it started adding the strings when instead of esc_html_e i wrote:

    icl_register_string('mythemename','myvariable',$myvar);
    echo icl_t('mythemename','myvariable',$myvar );
    

    i’m sure there is more elegant solution but since this one works it’ll do for now.