PHP code example of qpfsoft / lang
1. Go to this page and download the library: Download qpfsoft/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/ */
qpfsoft / lang example snippets
# en
[
'welcome' => 'Hello {:name}, nice to meet you!',
]
# zh
[
'welcome' => '你好 {:name}, 见到你很高兴!',
]
// simple 对应 @root/langs/zh-cn/simple.php 语言包
$lang->translate('simple', 'welcome', ['name'=>'qpf'], 'en-us'); // 'Hello qpf, nice to meet you!'
$lang->translate('simple', 'welcome', ['name'=>'qpf'], 'zh-cn'); // '你好 qpf, 见到你很高兴!'
$lang->translate('simple', 'welcome', ['name'=>'qpf']); // 可通过设置首选语言类型, 或客户端语言类型检查后, 可忽略
[
'phrase' => [
'Phrase is for better translation' => '短语是为了更好的翻译',
],
'word' => [
't' => [
'translate' => '翻译', // 推荐, 首字母分组
],
'translate' => '翻译', // 若存在首字符分组, 该词将无效
],
]
$this->lang->translate('precision', 'translate ok!', 'zh-cn'); // `翻译 ok!`
$this->lang->translate('precision', 'Phrase is for better translation', 'zh-cn'); // `短语是为了更好的翻译`
$this->lang->translate('precision', 'translate ok!', 'en-us'); // `translate ok!`