Giter Club home page Giter Club logo

composer-wp-language-updater's Introduction

composer-wp-language-updater's People

Contributors

khromov avatar pelmered avatar richardsweeney avatar tyrann0us avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

msalaj

composer-wp-language-updater's Issues

Hooks "post-package-install" and "post-package-update" inappropriate?

post-package-install and post-package-update will only be executed after package installation/update (see https://getcomposer.org/doc/articles/scripts.md#package-events). But language packs change independently of the package they belong to. At any time, translations can be updated/changed in GlotPress. AFAIK these language updates won't get installed with the currently used hooks.

So the more appropriate hooks probably should be post-install-cmd and post-update-cmd (see https://getcomposer.org/doc/articles/scripts.md#command-events) even if this causes the script to run more frequently.

When using the mentioned hooks though, I get the following fatal error:

> AngryCreative\WPLanguageUpdater\PostUpdateLanguageUpdate::install_t10ns
Fatal error: Uncaught TypeError: Argument 1 passed to AngryCreative\WPLanguageUpdater\PostUpdateLanguageUpdate::install_t10ns()
must be an instance of Composer\Installer\PackageEvent, instance of Composer\Script\Event given,
called in phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php on line 292
and defined in /path/to/project/vendor/pelmered/composer-plugin-language-update/src/PostUpdateLanguageUpdate.php:42
 Stack trace:
 #0 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(292):
AngryCreative\WPLanguageUpdater\PostUpdateLanguageUpdate::install_t10ns(Object(Composer\Script\Event))
 #1 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(215):
Composer\EventDispatcher\EventDispatcher->executeEventPhpScript('AngryCreative\\W...', 'install_t10ns', Object(Composer\Script\Event))
 #2 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(81): Composer\EventDispatcher\EventDispatcher->doDispatch(Object in
/path/to/project/vendor/pelmered/composer-plugin-language-update/src/PostUpdateLanguageUpdate.php on line 42
Failed to update packages for  ./composer.json.

What do you think? Should the hooks be changed?

Any feedback appreciated! Thanks!

Call to undefined method locate_wp_content()

scripts property of composer.json:

"scripts": {
  "post-package-install": [
    "AngryCreative\\WPLanguageUpdater\\PostUpdateLanguageUpdate::install_t10ns"
  ],
  "post-package-update": [
    "AngryCreative\\WPLanguageUpdater\\PostUpdateLanguageUpdate::update_t10ns"
  ]
}

When running composer update I get the following fatal error:

> AngryCreative\WPLanguageUpdater\PostUpdateLanguageUpdate::update_t10ns
 
 Fatal error: Uncaught Error: Call to undefined method AngryCreative\WPLanguageUpdater\PostUpdateLanguageUpdate::locate_wp_content()
in /Applications/AMPPS/www/mtrix.test/vendor/pelmered/composer-plugin-language-update/src/PostUpdateLanguageUpdate.php:110
 Stack trace:
 #0 /Applications/AMPPS/www/mtrix.test/vendor/pelmered/composer-plugin-language-update/src/PostUpdateLanguageUpdate.php(75):
AngryCreative\WPLanguageUpdater\PostUpdateLanguageUpdate::set_config()
 #1 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(292):
AngryCreative\WPLanguageUpdater\PostUpdateLanguageUpdate::update_t10ns(Object(Composer\Installer\PackageEvent))
 #2 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(215):
Composer\EventDispatcher\EventDispatcher->executeEventPhpScript('AngryCreative\\W...', 'update_t10ns', Object(Composer\Installer\PackageEvent))
 #3 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(116):
Composer\EventDispatcher\EventDispatcher->doDispatc in /Applications/AMPPS/www/mtrix.test/vendor/pelmered/composer-plugin-language-update/src/PostUpdateLanguageUpdate.php on line 110
 Failed to update packages for  ./composer.json.

I'm using https://github.com/dnaber-de/wpstarter-boilerplate if that's relevant.
Related: #2.

Change name and namespace of package.

This package manages translations for not only plugins so we need a new name the better reflect this functionality.

Also the namespace should be changed.

Don't use Guzzle to download translations

Recently, we had a lengthy internal discussion about a Composer based solution to get translations. The main reservation against this package (beside the fact that the code isn't really "clean") was that it uses Guzzle to download the translations:

The chances you get a dependencies conflict for something that is not even needed in production is very high. Ideally, building scripts should have no dependencies at all, but a such popular and big dependency like Guzzle is clearly a non-best practice.

@gmazzap

An appropriate alternative is Composer's RemoteFilesystem class or even just file_get_contents() as in @bjornjohansen's wplang.

Maybe you want to follow wecodemore/wpstarter#44, especially wecodemore/wpstarter#44 (comment) as this covers all requirements of a Composer based translation download in a modern WordPress stack.

Wordpress core language files not downloaded

Hi,

I am using bedrock wordpress and plugin and theme language files are downloaded, but no wordpress core language files.

I was looking into your code and found this:

case 'package':
if ( 'johnpbloch/wordpress' === $package->getName() ) {
$this->package_type = 'core';
$this->slug = 'wordpress-core';
break;
}

I am using root/wordpress package for core, so looks like this would be a problem. Aren't there other way of determining core package except name?

Michal

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.