PHP code example of benegedeniz / langy

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

    

benegedeniz / langy example snippets



     $lang = new Langy;

    // Setting the language file extension. (If you don't set it, this will default to "langy".)
    $lang->setLangExt("langy");

    // Setting the folder that contains language files. (Language files must end with the extension you set and must be in JSON format.) 
    $lang->setLangDir("languages"); 

    // Setting the language. (This must be the name of the desired language file. Exclude extension.)
    $lang->setLang("en"); 

    
 echo $lang->echo("title"); // Echoing a language item from the language file. 
 
                // Assigning language item to variable.
                $text = $lang->get("pageContent.header");
                echo $text;
            
 $lang->echo("pageContent.classAuthor"); 
 $lang->echo("pageContent.helloLangy.helloMsg"); 
 $lang->echo("pageContent.helloLangy.helloMsgWithVars", ["iamavariable" => "Langy"]);