PHP code example of rinkattendant6 / json-i18n

1. Go to this page and download the library: Download rinkattendant6/json-i18n 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/ */

    

rinkattendant6 / json-i18n example snippets




$t = new \JsonI18n\Translate('en-CA');
// By default, strings will be outputted in the locale given in the constructor
// In this case, Canadian English will be returned unless explicitly stated otherwise

// Optional settings
$t->setSettings([
    'strict' => false,
]);

$t->addResource('path/to/file.json');

$t->_ef('greeting', 'Jason'); // prints out "Hello"

$t->addSubresource('path/to/another/file.json', 'de-DE');

$t->_e('bye', 'fr-CA');

$input = [
    'label_en_CA' => 'Name',
    'label_fr_CA' => 'Nom',
];
$output = $t->localizeDeepArray($input, 'label', 0, 'en-CA');

// $output will be: ['label' => 'Name']