定制 themahabbat/lang 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

themahabbat/lang

Composer 安装命令:

composer require themahabbat/lang

包简介

Language changer

README 文档

README

Language changer for PHP

Initialization

Add "minimum-stability": "dev" to composer.json

Run composer require themahabbat/lang

Parameters

current: Current language

available: Array of available languages

dir (optional): Directory of language files exists (default: lang)

default: Default language if current language doesn't match available languages

cookie (optional): Cookie name (default: LANG)

cookieExpire (optional): Expire time for cookies in Unix timestamp (default: 168 days)

How it works

Script finds .json files in given language directory then initializes it

Code

<?php
require_once 'vendor/autoload.php';

use Mahabbat\Lang;

$L = Lang::init([

  'current' =>      $_GET['lang'],
  'available' =>    ['az', 'en'],
  'default' =>      'az',
  'cookie' =>       'LANG',
  'cookieExpire' => time()+86400*24*7

]);

Usage

Single Key

Gets keyName from current language's json file

Example JSON: { "keyName": "Hi there!" }

<?php
echo $L->key('keyName');  // Hi there!

Nested keys

Example JSON: { "keyName": [ {"inside": "This is the value inside keyName" } ] }

<?php
echo $L->key('keyName@inside');   // This is the value inside keyName

Variables

Example JSON: { "keyName": "Hello :name !" }

$values = [ 'name' => 'Mahabbat!' ];
echo $L->key('keyName', $values);   // Hello Mahabbat !

统计信息

  • 总下载量: 16
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-04-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固