Scan php files/project and create .po file, used for localization. It will extract all strings like __('txt').
PHP Shell
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

GetText PHP scanner

Created by Eslam Mahmoud


PHP class to scan files/project and create or update .po file, used for localization. Could be used to scan any type of files, It will extract all strings like __('Hello World') Or _e("Hello again.").


  • $directory to be scanned accept array of directories or single string directory
  • $file_extensions an array of allowed files extensions to be scanned

How to use it?

    //Example of how to use this class
    require_once './gettext.php';
    $gettext = new gettext();
    $lines = $gettext->scan_dir();
    echo count($lines) . ' lines have been collected and need to be translated <br>';
    if ($gettext->create_po($lines))
        echo '"' . $gettext->file_name . '" file has been created in the same directory of this script find it at <a href="' . $gettext->file_name . '">download ' . $gettext->file_name . '</a>';
        echo 'Error could not create the file please check if you have the right permissions';