PHP code example of jsnlib / translg

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

    

jsnlib / translg example snippets


{
    "  "jsnlib/translg": "1.0.1"
    }
}





$translg = new \Jsnlib\Codeigniter\Translg();

// 語言是英文時
// 會讀取 application/language/english/menu_lang.php 中的 $lang['news'] 
echo $translg->english->menu->news;


// 語言是正體中文時
// 會讀取 application/language/zh/menu_lang.php 中的 $lang['news'] 
echo $translg->zh->menu->news; 


$translg->語言名稱->分類文件->語言辨識鍵;

$translg->zh->menu->about;
$translg->zh->menu->news;
$translg->zh->menu->contact;

$lang = $_SESSION['switch_language]';
$translg->$lang->menu->about; // 依照 session 切換