PHP arrays for localization

Single array definition per file is supported

Returning an array is supported

<?php

return [
    'key' => 'Value',
    'another_key' => 'Another value',
    ...
    'extracted' => 'Extracted string will be added like this',
    ...
    'some_key' => [
        'nested_key' => 'Nested keys are also supported',
    ],
    ...
    'multiline' => 'An explicitly multiline strings
        will be extracted like this.'
];

Array assignment is supported

<?php

$lang = [
    'key' => 'Value',
    'another_key' => 'Another value',
    ...
    'extracted' => 'Extracted string will be added like this',
    ...
    'some_key' => [
        'nested_key' => 'Nested keys are also supported',
    ],
    ...
    'multiline' => 'An explicitly multiline strings
        will be extracted like this.'
];

Indentation

Configure formatting at the IDE level in Preferences | Editor | Code Style | PHP.

Unsupported formats

Request support at i18n-ally@lokalise.com.

Appending to an array is not supported

<?php

$lang = [];
$lang['key'] = 'Value';
$lang['another_key'] = 'Appending to an array is not supported';

Only the latest array definition is supported

$first = [
    'key' => 'This array definition will be ignored',
];

$latest = [
    'another_key' => 'Only the latest array definition is supported',
];

Translations nested after a different key are not supported

Nested translations are only supported if they start from the root. In the sample below, the translations are after a different key which is not supported.

<?php

return [
    'metadata' => [
        'non_translation_key' => true,
    ],
    'translations' => [
        'key' => 'This is NOT supported, because i18n Ally calls it like `translations.key` while the app would use just `key`',
    ],
];

Complex structures within a key are not supported

<?php

return [
    'key' => [
        'translation' => 'Complex structure per key is NOT supported',
        'notes' => '',
    ],
];