PHP
The PHP ecosystem does not have a single standard internationalization system. While Gettext PO is common, a simpler approach involves using PHP snippets and definitions to create key-value pairs. LingoHub supports these PHP resource files for streamlined localization.
Format
- Each
definestatement must end with a semicolon;. - The
definekeyword is case-insensitive (e.g.,defineorDEFINE). - Keys and values can be enclosed in single or double quotes.
- Supported placeholders include standard printf formatters such as
%s,%d, and%3.4d. - Comments beginning with
#are parsed and assigned as descriptions to the subsequent segment. - Newlines can be escaped using
\n. - LingoHub supports single-line
definestatements; multi-line statements are not supported. - Content before the first
defineline and after the lastdefineline is preserved and exported exactly as imported.
Example
Additional example files are available on GitHub.
<?php
# File header comment.
# 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.");
?>References
Updated about 1 month ago
