Last active
August 29, 2015 14:04
-
-
Save onnimonni/8ea503bb8d2e2a113529 to your computer and use it in GitHub Desktop.
Install Wordpress languages from languages.koodimonni.fi with this composer script. Place it in scripts/Koodimonni/Installer.php or just copy installLanguages() function to your composer scripts and require it after install/update.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Koodimonni; | |
use Composer\Script\Event; | |
class Installer { | |
public static function installLanguages(Event $event) { | |
$io = $event->getIO(); | |
$extra = $event->getComposer()->getPackage()->getExtra(); | |
if (!empty($extra['wordpress-languages-dir'])) { | |
$root = dirname(dirname(__DIR__)); | |
$wp_languages_folder = "{$root}/{$extra['wordpress-languages-dir']}"; | |
$wp_languages_vendor = "{$root}/vendor/koodimonni-language"; | |
if (!file_exists($wp_languages_folder)) { | |
$io->write("{$wp_languages_folder} Doesn't exist. If this is correct, please create it!"); | |
exit(1); | |
} | |
$io->write("Copying languagefiles into: {$wp_languages_folder}"); | |
//Use rsync to copy all but composer.json | |
exec("rsync -va {$wp_languages_vendor}/*/* {$wp_languages_folder} --exclude=composer.json"); | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment