ironsmile/php-translit 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

ironsmile/php-translit

最新稳定版本:v1.0.2

Composer 安装命令:

composer require ironsmile/php-translit

包简介

PHP library to convert text from one script to another.

README 文档

README

translit is a PHP library to convert text from one script to another. Currently it assume conversion of Cyrillic, Georgian, Armenian and Greek scripts into Roman (Latin). Cyrillic has sub-groups for Russian, Ukrainian, Belarusian, Bulgarian and Kazakh languages with custom rules.

Main class Translit could be used as singleton or object itself. Built-in translitaration tables could be refered by following language codes:

  • ru - Russian cyrillic chars,
  • uk - Ukrainian cyrillic chars,
  • mk - Macedonian cyrillic chars,
  • be - Belarusian cyrillic chars (converted to latin with diacritical),
  • bg - Bulgarian cyrillic chars (converted to latin with diacritical),
  • kk - Kazakh cyrillic chars (converted to latin with diacritical),
  • ka - Georgian chars,
  • hy - Armenian chars (converted to latin with diacritical),
  • el - Greek chars (converted to latin with diacritical),
  • cyrillic - all cyrillic chars according to ISO 9:1995,
  • latin - only latin chars without diacritical marks,
  • ascii - only ASCII chars, all non ASCII will be replaced with question mark.

Language codes could be combined by comma to handle more cases, e.g.

echo Translit::object()->convert('Беларусь', 'be') . ' vs ' . Translit::object()->convert('Беларусь', 'be,latin'); 

produce output:

Bielaruś vs Bielarus 

By default wrong language codes ignored. But this behavior could be changed by using strict mode. For all language codes that prepended with exclamation mark exception will be fired if any error (no conversion table, wrong format, empty). For example:

// following code returns 'Привет' as is because handler ru_ru not defined echo Translit::object()->convert('Привет', 'ru_ru') . PHP_EOL; // but next code fires Exception, because strict mode have used echo Translit::object()->convert('Привет', '!ru_ru') . PHP_EOL; 

There are many sources of these tables which could be used - ISO and BGN/PCGN standards, a lot of native standards and informal standard used by people. For this library I assume next order of sources - native, ISO, BGN/PCGN, informal.

All transliteration tables were created from information found at Wikipedia. The links to these pages posted into header of each file. Please update me if any mistakes found or you have new transliteration tables to add here.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固