PHP Array

Last modified: May 10, 2021Author: Jakub Pomykała

PHP Arrays are simple objects which can contain simple key-value entries. Where key is treated as unique translation key, and value which is translated message. One PHP file array contains language translations for only on language. For example: messages_de_DE.php contains translated message for German (Germany) locale.

File format example

<?php
    return [
        "HELLO_WORLD" => "Hello world!",
        "MY_TRANSLATION_KEY" => "This is my translation message!"
    ];
?>

Upload with CLI

simplelocalize upload --apiKey <PROJECT_KEY> \
  --uploadFormat php-array \
  --uploadPath ./messages_{lang}.php

Learn more about SimpleLocalize CLI and translations upload feature.

Download with CLI

simplelocalize download --apiKey <PROJECT_KEY> \
  --downloadFormat php-array \
  --downloadPath ./messages_{lang}.php

Learn more about SimpleLocalize CLI and translations download feature.

Import with API

curl
    --request POST \
    --url 'https://api.simplelocalize.io/api/v2/import?uploadFormat=php-array&languageKey=en' \
    --header 'x-simplelocalize-token: <API_KEY>' \
    --form file=@/path/to/your/messages.php

Learn more about importing translations with API

Export with API

curl
    --request GET \
    --url https://api.simplelocalize.io/api/v3/export?downloadFormat=php-array \
    --header 'x-simplelocalize-token: <API_KEY>'

Learn more about exporting translations with API