Supported File Types (Strings)

.PHP - Array (Strings)

Content is machine translated from English by Phrase Language AI.

File Extensions


API Extension






Plural forms support


Description support


An array is an ordered list or collection of items. The items of the array can be basically any type in PHP: a number, a string, an object, another array, etc. We often use strings as values in our locale message arrays. PHP arrays come in two major kinds:

  • Indexed — these arrays are ordered implicitly, e.g. ['red', 'green', 'blue']

  • Associative — these arrays contain pairs of keys (which can be integers or strings), and associated values, e.g. ['first_name' => 'Adam', 'last_name' => 'McMan', 'age' => 22]

The value of an array element can be set during initialization or using the variable name of the array itself.


// during initialization

$my_array = ['foo' => 'bar'];

// using variable name 

$my_second_array['key'] = 'value'

This method of setting values can be mixed and matched.

Working with Arrays

When pulling from the command line, message files will be sent in the following format using an associative, named array.


$lang['key'] = 'translated message';

$lang['another_key'] = 'Another translated message';

Ensure app is set up to work with this kind of format. Don’t return an anonymous array in message files and use the name $lang for the messages array.

Code Sample


$lang['boolean_key'] = '--- true
$lang['empty_string_translation'] = '';
$lang['key_with_description'] = 'Check it out! This key has a description! (At least in some formats)';
$lang['key_with_line-break'] = 'This translations contains
a line-break.';
$lang['nested.deeply.key'] = 'Wow, this key is nested even deeper.';
$lang['nested.key'] = 'This key is nested inside a namespace.';
$lang['null_translation'] = '';
$lang['sample_collection'] = '---
- first item
- second item
- third item
$lang['simple_key'] = 'Just a simple key with a simple message.';
$lang['unverified_key'] = 'This translation is not yet verified and waits for it. (In some formats we also export this status)';
Was this article helpful?

Sorry about that! In what way was it not helpful?

The article didn’t address my problem.
I couldn’t understand the article.
The feature doesn’t do what I need.
Other reason.

Note that feedback is provided anonymously so we aren't able to reply to questions.
If you'd like to ask a question, submit a request to our Support team.
Thank you for your feedback.