PHP code example of elaborate-code / php-json-tongue

1. Go to this page and download the library: Download elaborate-code/php-json-tongue library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

elaborate-code / php-json-tongue example snippets


use ElaborateCode\JsonTongue\TongueFacade;

$tongue = new TongueFacade('/lang');

$localization = $tongue->transcribe();

$localization = [
    "es" => [
        "programmer" => "programador",
        "interviewer" => "entrevistador",
        "Hello" => "Hola",
        "Good morning" => "buenos dias",
        //...
    ],
    "fr" => [
        "Hello" => "Salut",
        "Good morning" => "Bonjour",
        //...
    ]
    //...
];

$json_faker = JsonFaker::make()
    ->addLocale('ar', [
        'ar.json' => [],
    ])
    ->addLocale('en', [
        'en.json' => [
            'en' => 'en',
            "I know. They're both good. It's hard to decide. McCain is older but he has more experience. Obama seems to have a lot of good ideas, but some people say he wants to raise taxes." => 'Lo sé. Ambos son buenos. Es difícil decidir. McCain es mayor pero tiene más experiencia. Obama parece tener muchas buenas ideas, pero algunas personas dicen que quiere aumentar los impuestos.',
        ],
        'one.json' => [
            'one' => 'one',
        ],
        'two.json' => [
            'two' => 'two',
        ],
    ])
    ->addLocale('multi', [
        'greetings.json' => [
            'en' => [
                'Hello' => 'Hello',
            ],
            'fr' => [
                'Hello' => 'Salut',
            ],
        ],
    ])
    ->write();

// Assert

$json_faker->rollback(); // Delete the complete file structure created for the test