1. Help Center
  2. Supported formats

Laravel/F3/Kohana Array

Everything you need to know about a Laravel/F3/Kohana array and its use in localization with Phrase

File Extensions .php
API Extension laravel
Import Yes
Export Yes
Pluralization supported? Yes*
Descriptions supported? No

*see section How Phrase works with Laravel Arrays below

Laravel uses plain PHP arrays for its locale message files. An array is basically an ordered list or collection of items. The items of the array can be any type in PHP: a number, a string, an object, another array, etc. We often use strings as values in our locale message arrays. Laravel uses associative arrays, which contain key-value pairs; it also has one anonymous array per message file – the file returns the array.

<?php

return [

    "hello" => "Welcome to my new site",

];

How Phrase works with Laravel Arrays

Phrase is built to work with Laravel out of the box, for the most part. Do watch out for plurals: the Phrase web editor recognizes Laravel’s simple plural syntax, e.g. “Zero things|One thing|Many things”. However, it does not recognize Laravel’s complex plural syntax with count and range specifiers (see code below). One workaround for complex plurals is to use newlines in your plural strings, which can help translators work with plurals in the Phrase web editor.

<?php

return [

    "hello" => "Welcome to my new site",

    // Supported in Phrase web editor 👇🏽

    "Simple_plural" => "Zero things|One thing|Many things",

        // Not supported in Phrase web editor 👇🏽, try to use new

    // lines to help translators.

    "complex_plural" => "

        {0} Zero things

        |{1} One thing

        |[2,*] Multiple things

    ",

];

Make sure to leave no spaces between the separators and specifiers in your string, e.g. “|{1}”, the | and { must have no space between them or Laravel will ignore them.

Code Sample

<?php
return array(
"boolean_key" => "--- true
",
"empty_string_translation" => "",
"key_with_description" => "Check it out! This key has a description! (At least in some formats)",
"key_with_line-break" => "This translations contains
a line-break.",
"nested" => array(
"deeply" => array(
"key" => "Wow, this key is nested even deeper.",
),
"key" => "This key is nested inside a namespace.",
),
"null_translation" => "",
"pluralized_key" => "You have no pluralization.|Only one pluralization found.|Wow, you have %s pluralizations!",
"sample_collection" => "---
- first item
- second item
- third item
",
"simple_key" => "Just a simple key with a simple message.",
"unverified_key" => "This translation is not yet verified and waits for it. (In some formats we also export this status)",
);

Learn More