daycry/codeigniter-language
最新稳定版本:v1.0.3
Composer 安装命令:
composer require daycry/codeigniter-language
包简介
Load language files as array in Codeigniter 4
README 文档
README
Codeigniter Language
Language for Codeigniter 4
Send translation files to Javascript
Installation via composer
Use the package with composer install
> composer require daycry/codeigniter-language
Manual installation
Download this repo and then enable it by editing app/Config/Autoload.php and adding the Daycry\Language namespace to the $psr4 array. For example, if you copied it into app/ThirdParty:
$psr4 = [ 'Config' => APPPATH . 'Config', APP_NAMESPACE => APPPATH, 'App' => APPPATH, 'Daycry\Language' => APPPATH .'ThirdParty/codeigniter-language/src', ];
Usage Loading Library
$language = new \Daycry\Language\Language( \Config\Services::request()->getLocale() ); $language->loadFile( 'Validation' ); var_dump( $language->getTraductions() );
Usage as a Service
$language = \Config\Services::language(); $language->loadFile( 'Validation' ); var_dump( $language->getTraductions() );
Usage In Views
Twig
Use the package with composer install
> composer require daycry/twig
$this->twig->addGlobal( 'traductions', $this->language->getTraductions() );
<script> var traductions = {{ traductions|json_encode|raw }}; console.log( traductions['File']['string'] ); </script>
Codeigniter Views
echo view( 'some_view' );
<script>
var traductions = <?php echo json_encode( $this->language->getTraductions() ); ?>;
console.log( traductions['File']['string'] );
</script>
统计信息
- 总下载量: 1.22k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-06-10