PHP Localization

The PHP system does not have a standard i18n system. The usage of Gettext PO is quite common. If you are using PO or POT files to translate your PHPapplication please take a look at this article in our documentation.

A much simpler approach to internationalize your PHP application is the usage of PHP snippets and define to build key/value pairs.

Format

  • Each line must end with a “;” sign

  • The define keyword can be written as follows: “define” or “DEFINE”

  • Keys and values can be single or double quoted

  • Examples for placeholders are: “%s”, “%10s”, “%d”, “%3.4d”

  • A comment line starts with a “#” sign. Lingohub will parse these comments and assign them as description to the next segment.

  • Newlines can be escaped with “\n”

  • Lingohub does not support multi line statements. Each define statement has to be finished in one line.

  • Every line before the first define line and after the last define line will be parsed without interpreting it as PHP code. It will be exported as it was imported.

Example

Additional example files can be accessed here.

<?php
  # A header comment for
  # the file.

  # a comment for the LOGOFF segment
  define('LOGOFF', 'Log off');
  define("DOUBLE_QUOTES", "'single' and \"double\" quotes");
  define("SINGLE_QUOTES", '\'single\' and "double" quotes');
  DEFINE('PLACEHOLDER', 'Hello %s!');
  DEFINE('MULTI_LINE', 'A multi line \n string.');
?>

Last updated