Translate PHP Array files

What are PHP Array files?

PHP Array files are PHP files used as language files to localize PHP apps. Their file extension is .php.

WebTranslateIt is a software localization platform that can help localize PHP Array .php files.

PHP Array file example

PHP Arrays come in 2 flavours, which are described below:

<?php
$lang = array(
  'string0' => 'some text',
  'string1' => 'some text
with a linebreak.',
  'string2' => 'some text with a\' quote',
  # a comment
  'string3' => "some text with a ' quote",
); ?>
<?php
  $LANG['_MONDAY'] = "Monday";
  $LANG["_TUESDAY"] = 'Tuesday';
  // This is a comment
  $LANG["_WEDNESDAY"] = '';
  $LANG["_Thursday"] = "Thursday";
?>
  • Each string must end with a ,, except for the last string of the Array where comma is optional.
  • Strings can contain linebreaks.
  • $lang can be replaced by any other variable or array, for instance $LOCALE = array() or $LANG['fr'] = array().
  • Make sure to add a newline between $lang = array( and the list of strings.
  • Strings can be single quoted or double quoted.
  • If a string is single quoted, single quotes must be escaped.
  • If a string is double quoted, double quotes must be escaped.
  • Instructions can be left to translators by including a line starting by #.
  • The PHP closing tag ?> is optional. If no PHP closing tag is present when importing a file WebTranslateIt will generate files without a closing tag.

Magic Comments

This file handler support the following magic comments:

  • Comments containing [MAXCHAR=xx] will set a max character limit to xx. Example: # [MAXCHAR=20]
  • Comments containing [LABEL=xxxx] will assign the label to xxxx. Example: // [LABEL=new feature]

Related File Formats

Related Platforms