定制 scento/lingua 二次开发

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

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

scento/lingua

最新稳定版本:1.0.0

Composer 安装命令:

composer require scento/lingua

包简介

Lingua is an internationalization toolkit.

README 文档

README

Build Status Coverage Status Packagist Version Dependencies

Motivation

Imagine you have to develop a web application for a worldwide audience. How do you manage to respect the cultural differences of the people you are working for on different levels? The problematic fields not only cover the language and different input methods, but also charsets, timezones, regional dialects, units and many other things, which are standardized per-country or per-region.

This project aims to support the development of interculural PHP applications by providing standardized interfaces and classes to utilize global coding standards and a buch of conversion table resources to provide a unified library for Locale management.

The library is supposed to integrate into existing PHP frameworks and works with a minimal configuration effort, while being highly modular, keeping the ability to change every subsystem, depending on the project needs.

Installation

One can download and install this library using composer:

composer require scento/lingua

Lingua needs to download some data before being able to work. The entire process can happen automatically, but you need to accept the different licenses of the sources to use the data. Whenever you need to embed this library into own projects, remember to integrate a way to trigger this process including showing the licenses.

<?php
//Create a preinitialized setup environment
$setup = Lingua\Setup::prelude();

//Showing all terms of use
echo "You accept the the following terms of use:";
foreach ($setup->getLicenses() as $source => $license) {
    echo "\n\n---\t".$source."\t---\n";
    echo $license."\n";
}

//Download and process the required data
$setup->acceptAndDownload();

The Setup process can utilize a PSR-3 logging handler.

Use Cases

Lingua support many different use cases, some of them are described or shown in the examples. Some advanced use cases are described in the in-detail documentation. The current version supports:

Code Conversion

The following lines show the basic method to translate between coding standards. There are more examples available.

<?php
$iso639Part1 = new Lingua\Code\Language\ISO639Part1();
$iso639Part2B = new Lingua\Code\Language\ISO639Part2B();

echo $iso639Part2B->translate($iso639Part1->unify('de'));

Code Validation

The following example shows how to validate a code. Some more examples are available.

<?php
$iso15924 = new Lingua\Code\Script\ISO15924();
echo '`Latn` is '.($iso15924->validate('Latn') ? 'a' : 'no').' valid ISO 15924 code.';

Supported Standards

To unify and translate different resources depending on codings, this library supports the following standards:

Language Region Script
ISO 639-1 ISO 3166-1 Alpha-2 ISO 15924
ISO 639-2B ISO 3166-1 Alpha-3
ISO 639-2T
ISO 639-3

Development

To learn more about the development process, read our contribution guide - basically we follow and utilize:

Licenses

This project is licensed under the terms of the MIT License.

统计信息

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

GitHub 信息

  • Stars: 9
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-02-27