PHP code example of jbzoo / lang

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

    

jbzoo / lang example snippets




// Get needed classes
use JBZoo\Lang\Lang;

// Create
$lang = new Lang('en');                             // Pass language code (only two chars!)

// Paths, modules, overload
$lang->load('./somepath/glob/');                    // ./somepath/glob/langs/en.php
$lang->load('./somepath/glob/', 'module_name');     // ./somepath/glob/langs/en.module_name.php
$lang->load('./somepath/module/', 'module_name');   // ./somepath/module/langs/en.module_name.php (overload previous)

// Other formats
$lang->load('./somepath/glob/', null, 'php');   // ./somepath/glob/langs/en.php
$lang->load('./somepath/glob/', null, 'json');  // ./somepath/glob/langs/en.json
$lang->load('./somepath/glob/', null, 'ini');   // ./somepath/glob/langs/en.ini
$lang->load('./somepath/glob/', null, 'yml');   // ./somepath/glob/langs/en.yml  (Symfony/Yaml)

// Traslate
$lang->translate('message_key');                // Only global
$lang->translate('module_name.message_key');    // Check module "module_name" and after that global path