PHP code example of aligurbuz / lingua

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

    

aligurbuz / lingua example snippets



use Lingua\Lingua;



//it is set to the as "en" value of default locale in the langdir directory.
$lang=(new Lingua('path/to/langDir'));

//It prints all the keys in message.yaml (in that path/to/langDir/en)
echo $lang->get('message');

//it is set to the as fr in the langdir directory.
//It prints all the keys in message.yaml (in that path/to/langDir/fr)
echo $lang->locale('fr')->get('message');

//It prints key called foo in message.yaml (in that path/to/langDir/en)
echo $lang->get('message.foo');

//It prints keys specified in array as parameters in message.yaml (in that path/to/langDir/en)
echo $lang->get('message',['foo','bar']);

//if specified exclude as key in array as parameters in message.yaml (in that path/to/langDir/en)
//In this case, the strings in the exclude array are removed from the called file.
echo $lang->get('message',['exclude'=>['foo']);




//It prints all the keys in message.yaml and default.yaml (in that path/to/langDir/en)
echo $lang->/langDir/en)
echo $lang->


//It prints key that in both default.yaml and all files in load directory if there is no key specified in message.yaml (in that path/to/langDir/en)
echo $lang->