Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting "Undefined index: messages" Exception in MultidimensionalArrayTrait.php: 78 #3

Open
kajes opened this issue Aug 18, 2017 · 1 comment

Comments

@kajes
Copy link

kajes commented Aug 18, 2017

I'm using gettext/gettext and gettext/robo for translating two different (but interconnected) pages. The first I'm only using it to translate the js-files with no problem. The second one, however, translates both php- and js-files and Robo keeps throwing this error multiple times (presumably when it finds a translatable string.
This doesn't seem to bother much though since the Robo script finishes the scanning and generates a valid pot-file in the end.

Here's the error that gets printed when Robo has finished scanning:

ERROR: Invalid argument supplied for foreach() in [...]/vendor/gettext/gettext/src/Utils/MultidimensionalArrayTrait.php:78

Robofile.php:

require "../vendor/autoload.php";

class RoboFile extends \Robo\Tasks
{
    use Gettext\Robo\GettextScanner;

    public function gettext()
    {
        $this->taskGettextScanner()
            ->extract("../", "/.*\.js/")
            ->extract("../", "/.*\.php/")
            ->generate("messages.pot")
            ->run();
    }
}

Running a debugger when Robo runs gives the error in the title.

@oscarotero
Copy link
Member

This may be due the regular expression that not contains the final keyword ($), so "/.*\.js/" matches for files with the extension .json. Try changing the regular expression to "/.*\.js$/"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants