I18N Shell

The i18n features of CakePHP use po filesas their translation source. PO files integrate with commonly used translation toolslike Poedit.

The i18n shell provides a quick and easy way to generate po template files.These templates files can then be given to translators so they can translate thestrings in your application. Once you have translations done, pot files can bemerged with existing translations to help update your translations.

Generating POT Files

POT files can be generated for an existing application using the extractcommand. This command will scan your entire application for __() stylefunction calls, and extract the message string. Each unique string in yourapplication will be combined into a single POT file:

  1. bin/cake i18n extract

The above will run the extraction shell. The result of this command will be thefile src/Locale/default.pot. You use the pot file as a template for creatingpo files. If you are manually creating po files from the pot file, be sure tocorrectly set the Plural-Forms header line.

Generating POT Files for Plugins

You can generate a POT file for a specific plugin using:

  1. bin/cake i18n extract --plugin <Plugin>

This will generate the required POT files used in the plugins.

Extracting from multiple folders at once

Sometimes, you might need to extract strings from more than one directory ofyour application. For instance, if you are defining some strings in theconfig directory of your application, you probably want to extract stringsfrom this directory as well as from the src directory. You can do it byusing the —paths option. It takes a comma-separated list of absolute pathsto extract:

  1. bin/cake i18n extract --paths /var/www/app/config,/var/www/app/src

Excluding Folders

You can pass a comma separated list of folders that you wish to be excluded.Any path containing a path segment with the provided values will be ignored:

  1. bin/cake i18n extract --exclude vendor,tests

Skipping Overwrite Warnings for Existing POT Files

By adding —overwrite, the shell script will no longer warn you if a POTfile already exists and will overwrite by default:

  1. bin/cake i18n extract --overwrite

Extracting Messages from the CakePHP Core Libraries

By default, the extract shell script will ask you if you like to extractthe messages used in the CakePHP core libraries. Set —extract-core to yesor no to set the default behavior:

  1. bin/cake i18n extract --extract-core yes
  2.  
  3. // or
  4.  
  5. bin/cake i18n extract --extract-core no