cedaro / grunt-wp-i18n

Internationalize WordPress themes and plugins with Grunt.
MIT License
160 stars 25 forks source link

Detecting msgid stored in variable #77

Closed regisphilibert closed 6 years ago

regisphilibert commented 6 years ago

I don't really see how this is doable, but here is my issue: Some translatable strings are stored in variables and are declared this way:

    foreach($object as $k => $v){
        $output .= '<dt>' . __($k, 'cm') . '</dt>';
        foreach($v as $item){
            $output .= '<dd>' . $item . '</dd>';
        }
    }

grunt-wo-i148n does not detect those strings (which makes sense). I could add them by hand, but every time I'll run makepot, I'll have add them again.

I'm wondering:

  1. Is there anyway to make those strings detectable ?
  2. Is there a way to easily add some strings manually during build with an option or through processPot

Thanks for keeping the good work, this package is a must!

bradyvercher commented 6 years ago

Hi @regisphilibert, It's not possible to detect those strings since the code isn't executed. Your best bet is to wrap the strings in an i18n function where they're assigned to the variable instead of passing the variable as an argument into the function like that.

If that's not possible, you just need to have the strings wrapped in an i18n call somewhere in your project, even if it's in a dummy file that isn't used anywhere else in your project.