PHP
The PHP system does not have a standard i18n system.
The usage of Gettext PO is quite common. If you use .po
or .pot
files to translate your PHP application, please look at this article in our documentation.
A much simpler approach to internationalizing your PHP application is to use PHP snippets and definitions to build key/value pairs.
Format
- Each line must end with a
;
sign - The define keyword can be written as follows:
define
orDEFINE
- Keys and values can be single or double-quoted
- Examples of placeholders are:
“%s”, “%10s”, “%d”, “%3.4d”
- A comment line starts with a
#
sign. Lingohub will parse these comments and assign them as descriptions 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.
Examples
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.');
?>
Updated 17 days ago