---
title: "Laravel: What's wrong with my PHP translation files?"
description: "BabelEdit supports only simple PHP files with a single return statement returning string-to-string arrays."
canonical: "https://www.codeandweb.com/babeledit/knowledgebase/laravel-php-error"
product: "babeledit"
source: "html"
---

# Laravel: What's wrong with my PHP translation files?

BabelEdit can only read simple PHP translation files with a specific structure. It does not support complex PHP code or logic in these files.

Supported format requirements:

*   The file must contain exactly one return statement, with no other PHP code.
*   The return value must be an array.
*   Array keys and values must be string literals ("key" => "value").
*   Nested arrays are allowed (see example below).

✅ Example of a valid translation file:

```php
<?php
return [
    "app_name" => "Example",
    "greeting" => "Hello world!",
    "common" => [
        "dateranges" => [
            "custom" => "Custom",
            "last_7d" => "Last 7 days",
            "last_28d" => "Last 28 days"
        ]
    ]
];
```

❌ Example of unsupported PHP code:

```php
<?php
declare(strict_types=1)              // ERROR: Extra code not allowed
return [
    "app_name" => appName(),         // ERROR: Functions not allowed
    "greeting" => "Hello " . $p,     // ERROR: Variables not allowed
    "common" => [
        "dateranges" => [
            "custom" => "Custom",
            7 => "Last 7 days",      // ERROR: Keys must be strings
            28 => "Last 28 days"
        ]
    ]
];
```

Typical error messages:

*   _Only a single return statement is allowed in the translation file._
*   _Translation id must be a string literal_
*   _Translation for id 'name' must be a string literal_

## Structured data

```json
{
  "@context": "https://schema.org",
  "@type": "TechArticle",
  "headline": "Laravel: What's wrong with my PHP translation files?"
}
```
