定制 intelligenia/behistun 二次开发

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

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

intelligenia/behistun

Composer 安装命令:

composer require intelligenia/behistun

包简介

A simple translation manager for your PHP application

README 文档

README

Behistun is a simple PHP translation manager

Requirements

PHP 5.4 and dependencies installed by composer (AdoDB and Twig template system).

Installation

Install from packagist typing:

composer install

Configuration

Define the available languages

// For example we are going to translate to Spanish and French
$LANGUAGES = ["es_ES", "fr_FR"];

Load the file init.php file from the behistun package

Load the init.php file in your index.php or init.php file.

require_once __DIR__ . '/vendor/intelligenia/behistun/behistun/init.php';

Use

Templates

This package relies on the Twig template system so you will have to use the following Twig tag to mark a block of text as translatable:

{% translatable '<id>' %}
This text will be translated
{% endtranslatable %}

The id will be used to identify the block of translatable text when dealing with translations. You should set it to value that helps you recognize easily the block it represents.

Compile all source texts from templates

Run this PHP script that will get all the source texts and create a locales/LANGUAGE_CODE/LC_MESSAGES/ directory in the same directory your templates:

php vendor/intelligenia/behistun/behistun/bin/update_translations.php <template-path> <language> [purge]

For example:

php vendor/intelligenia/behistun/behistun/bin/update_translations.php ~/projects/my-web/public_html/templates/ en_US

Translation

This locales/LANGUAGE_CODE/LC_MESSAGES/ directory contains two files:

web.source.php

Original association between translatable ids and source texts.

web.translation.php

Where each translation goes. Remember that each translation is identified by the id you used in the translatable tag.

Changing language

// Call Translator class with the language code you want to translate the texts
// this code only should be executed once, when you have a selected language that is
// different from the default language (e.g. English if your web is for English-speaking people)
$translator = new Translator($LANGUAGE);

License

MIT License.

Authors

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 5
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-04-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固