From 113288c4b13bfd9e51758fcfde760167fa9c41bd Mon Sep 17 00:00:00 2001 From: "Dominik Schilling (ocean90)" Date: Sat, 20 Feb 2016 21:02:33 +0000 Subject: [PATCH] i18n-tools: Add the ability to parse a whole directory with add-textdomain.php. Props iamntz. Fixes #35499. git-svn-id: https://develop.svn.wordpress.org/trunk@36600 602fd350-edb4-49c9-b593-d223f7449a82 --- tools/i18n/add-textdomain.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tools/i18n/add-textdomain.php b/tools/i18n/add-textdomain.php index f7fa28b3fd..14eabf1991 100644 --- a/tools/i18n/add-textdomain.php +++ b/tools/i18n/add-textdomain.php @@ -93,7 +93,7 @@ class AddTextdomain { // wasn't included $included_files = get_included_files(); if ($included_files[0] == __FILE__) { - $adddomain = new AddTextdomain; + $adddomain = new AddTextdomain(); if (!isset($argv[1]) || !isset($argv[2])) { $adddomain->usage(); @@ -106,7 +106,15 @@ if ($included_files[0] == __FILE__) { array_shift($argv); } - $adddomain->process_file($argv[1], $argv[2], $inplace); + if ( is_dir( $argv[2] ) ) { + $directory = new RecursiveDirectoryIterator( $argv[2], RecursiveDirectoryIterator::SKIP_DOTS ); + $files = new RecursiveIteratorIterator( $directory ); + foreach ( $files as $file ) { + if ( 'php' === $file->getExtension() ) { + $adddomain->process_file( $argv[1], $file->getPathname(), $inplace ); + } + } + } else { + $adddomain->process_file( $argv[1], $argv[2], $inplace ); + } } - -?>