• I am having an issue with the new make-json functionality in WP-CLI
    I am following the tutorial here: https://pascalbirchler.com/internationalization-in-wordpress-5-0/#comments

    I created a plugin with a php and a js file, added a textdomain and added strings to both files. Then I created the .pot file (using wp i18n make-pot), and the .po and .mo files.

    Everything works as expected until I run
    wp i18n make-json ./languages

    Any help is much appreciated.

    Error

    PHP Warning:  file_get_contents(phar:///usr/local/bin/wp/vendor/gettext/languages/src/cldr-data/main/en-US/languages.json): failed to open stream: phar error: "vendor/gettext/languages/src/cldr-data/main/en-US/languages.json" is not a file in phar "/usr/local/bin/wp" in phar:///usr/local/bin/wp/vendor/gettext/languages/src/CldrData.php on line 72
    PHP Warning:  Invalid argument supplied for foreach() in phar:///usr/local/bin/wp/vendor/gettext/languages/src/CldrData.php on line 37
    PHP Warning:  file_get_contents(phar:///usr/local/bin/wp/vendor/gettext/languages/src/cldr-data/main/en-US/territories.json): failed to open stream: phar error: "vendor/gettext/languages/src/cldr-data/main/en-US/territories.json" is not a file in phar "/usr/local/bin/wp" in phar:///usr/local/bin/wp/vendor/gettext/languages/src/CldrData.php on line 74
    PHP Warning:  Invalid argument supplied for foreach() in phar:///usr/local/bin/wp/vendor/gettext/languages/src/CldrData.php on line 37
    PHP Warning:  file_get_contents(phar:///usr/local/bin/wp/vendor/gettext/languages/src/cldr-data/supplemental/plurals.json): failed to open stream: phar error: "vendor/gettext/languages/src/cldr-data/supplemental/plurals.json" is not a file in phar "/usr/local/bin/wp" in phar:///usr/local/bin/wp/vendor/gettext/languages/src/CldrData.php on line 76
    PHP Warning:  Invalid argument supplied for foreach() in phar:///usr/local/bin/wp/vendor/gettext/languages/src/CldrData.php on line 37
    PHP Warning:  file_get_contents(phar:///usr/local/bin/wp/vendor/gettext/languages/src/cldr-data/main/en-US/scripts.json): failed to open stream: phar error: "vendor/gettext/languages/src/cldr-data/main/en-US/scripts.json" is not a file in phar "/usr/local/bin/wp" in phar:///usr/local/bin/wp/vendor/gettext/languages/src/CldrData.php on line 78
    PHP Warning:  Invalid argument supplied for foreach() in phar:///usr/local/bin/wp/vendor/gettext/languages/src/CldrData.php on line 37
    PHP Fatal error:  Uncaught InvalidArgumentException: The language "en-US" is not valid in phar:///usr/local/bin/wp/vendor/gettext/gettext/src/Translations.php:356
    Stack trace:
    #0 phar:///usr/local/bin/wp/vendor/wp-cli/i18n-command/src/MakeJsonCommand.php(158): Gettext\Translations->setLanguage('en-US')
    #1 phar:///usr/local/bin/wp/vendor/wp-cli/i18n-command/src/MakeJsonCommand.php(97): WP_CLI\I18n\MakeJsonCommand->make_json('/home/mark/Desk...', '/home/mark/Desk...')
    #2 [internal function]: WP_CLI\I18n\MakeJsonCommand->__invoke(Array, Array)
    #3 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(93): call_user_func(Array, Array, Array)
    #4 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}(Array, Array)
    #5 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php(449): call_user_func(Object(Closure), Array, Array)
    #6 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(366): WP_CLI\Dispatcher\Subcommand->invoke(Array, Array in phar:///usr/local/bin/wp/vendor/gettext/gettext/src/Translations.php on line 356

    wp –info

    OS:	Linux 4.8.0-53-generic #56~16.04.1-Ubuntu SMP Tue May 16 01:18:56 UTC 2017 x86_64
    Shell:	/bin/bash
    PHP binary:	/usr/bin/php7.2
    PHP version:	7.2.12-1+ubuntu16.04.1+deb.sury.org+1
    php.ini used:	/etc/php/7.2/cli/php.ini
    WP-CLI root dir:	phar://wp-cli.phar/vendor/wp-cli/wp-cli
    WP-CLI vendor dir:	phar://wp-cli.phar/vendor
    WP_CLI phar path:	/home/mark/Desktop/html/tests/wordpress/wp-content/plugins/test
    WP-CLI packages dir:	
    WP-CLI global config:	
    WP-CLI project config:	
    WP-CLI version:	2.1.0
    • This topic was modified 5 years, 9 months ago by markcummins.
  • The topic ‘WP-CLI > make-json failed to open stream’ is closed to new replies.