Creates a .pot file for translations based off a directory of php files

0.0.3 2018-03-17 13:42 UTC

This package is auto-updated.

Last update: 2024-05-29 03:05:19 UTC


This is a really simple command line tool which generates a .pot or .po file based off language strings that it finds within the defined directory.

Currently it simply accepts 2 paths, an input - which should be a directory of templates, and an output, which is typically a .pot file.


  1. composer install owenmelbz/php-to-pot


Create a composer script to save your little fingers e.g

"scripts": {
	"makepot": "./vendor/bin/php-to-pot -i ./my-template-directory -o ./translation-template.pot"

You can then just run composer run makepot to generate your file when needed.


The tool has only 2 params

  1. -i/--in (a directory containing files you want to generate translations from)
  2. -o/--out (the path/filename of the generated .pot)


./vendor/bin/php-to-pot -i ./my-templates -o translation-template.pot


  • Magento 2
  • Wordpress
  • Laravel Blade
  • Anything else that uses .php extension and a list of the following translation functions

__ n__ p__ e d_ dn__ dp__ np__ dnp__ noop__ gettext ngettext pgettext dgettext dngettext dpgettext npgettext dnpgettext noop


Under the hood, this just interfaces with https://github.com/oscarotero/Gettext to allow developers to generate .pot files to send to translators to create the actual .po and .mo files.