PHP code example of yohns / lang

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

    

yohns / lang example snippets


use Yohns\Core\Config;
use Yohns\Lang\Text;

// Initialize Config for your application
new Config(__DIR__ . '/lib/Config');

// Initialize Text with language directory
$langDir = __DIR__ . '/lib/Lang';
$text = new Text($langDir, 'en'); // 'en' for English

// Basic usage
echo Text::L('welcome', 'Welcome to our site');
// Output: "Welcome to our site" (or translation if found)

// With placeholders
echo Text::L('hello_user', 'Hello, [name]!', ['[name]' => 'John']);
// Output: "Hello, John!"

// Dot notation for nested translations
echo Text::L('pages.about', 'About Us');
// Output: "About Us" (or translation if found)

public static L (string $key, string $default, array $replacements)

public __construct (string $dir, string $lingo)

public static getAll (void)

public static reload (void)

public static set (string $key, mixed $value)