PHP code example of eden / language

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

    

eden / language example snippets


//initial translations
$translations = array(
	'Hello'         => 'Bonjour',
	'How are you?'  => 'Como tale vous?');
 
//load up the translation   
$french = eden('language', $translations);
 
//you can add translations on the fly
$french->translate('I am good thank you, and you?', 'Bien mercy, et vous?');
 
//now echo some translations
echo $french->get('Hello'); //--> Bonjour
echo $french->get('How are you?'); //--> Como tale vous?
echo $french->get('I am good thank you, and you?'); //--> Bien mercy, et vous?

//initial translations
$translations = array(
	'Hello'         => 'Bonjour',
	'How are you?'  => 'Como tale vous?');
 
//load up the translation   
$french = eden('language', $translations);
 
//you can add translations on the fly
$french['I am good thank you, and you?] = 'Bien mercy, et vous?';
 
//now echo some translations
echo $french['Hello']; //--> Bonjour
echo $french['How are you?']; //--> Como tale vous?
echo $french['I am good thank you, and you?']; //--> Bien mercy, et vous?
 
foreach($french as $default => $translation) {
	echo $translation;
}

//load up a translation file
$translations = eden('file', '/path/to/french.php')->getData();
$french = eden('language', $translations);
 
//add to translation
$french['I am good thank you, and you?] = 'Bien mercy, et vous?';
 
//save back to file
$french->save('/path/to/french.php');

eden('language')->save(string|null $file);