wossnap/amharic-transliteration
Composer 安装命令:
composer require wossnap/amharic-transliteration
包简介
Laravel package for transliterating Amharic (Ethiopic) text to Latin and handling phonetically equivalent character variants.
README 文档
README
A Laravel package for transliterating Amharic (Ethiopic) text to Latin and handling phonetically equivalent character variants.
Amharic has several characters that share the same sound — for example አ, ዓ, ኣ, and ዐ are all pronounced the same way. This package maps every character to its Latin phonetic equivalent and provides tools to work with those variants in search, speech recognition, and admin interfaces.
Requirements
- PHP 8.1+
- Laravel 10, 11, or 12
Installation
composer require wossnap/amharic-transliteration
Laravel auto-discovers the service provider. No manual registration needed.
Quick start
use Wossnap\AmharicTransliteration\Facades\AmharicTransliteration; AmharicTransliteration::transliterate('ሰላም'); // → "selam" AmharicTransliteration::getAmharicVariants('አምሮ'); // → ["አምሮ", "ኣምሮ", "ዐምሮ", "ዓምሮ"]
You can also inject the service directly:
use Wossnap\AmharicTransliteration\AmharicTransliterationService; class WordController extends Controller { public function __construct( private AmharicTransliterationService $transliterator ) {} public function store(Request $request) { $transliterations = $this->transliterator->getSuggestedTransliterations( $request->input('word') ); } }
API reference
Core transliteration
transliterate(string $text): string
Transliterate a full Amharic string to its Latin phonetic equivalent. Non-Amharic characters (spaces, numbers, punctuation) pass through unchanged.
AmharicTransliteration::transliterate('ሰላም'); // "selam" AmharicTransliteration::transliterate('ደህና ሁን'); // "dehna hun" AmharicTransliteration::transliterate('hello ሰላም'); // "hello selam"
transliterateChar(string $char): ?string
Transliterate a single character. Returns null if the character has no mapping.
AmharicTransliteration::transliterateChar('ሰ'); // "se" AmharicTransliteration::transliterateChar('ላ'); // "la" AmharicTransliteration::transliterateChar('A'); // null AmharicTransliteration::transliterateChar(' '); // null
Variant handling
getAmharicVariants(string $word): array
Return every possible Amharic spelling of a word by substituting each character with all of its phonetically equivalent alternatives.
AmharicTransliteration::getAmharicVariants('አምሮ'); // ["አምሮ", "ኣምሮ", "ዐምሮ", "ዓምሮ"] AmharicTransliteration::getAmharicVariants('ሰላም'); // ["ሰላም", "ሠላም"]
getCharEquivalents(string $char): array
Return all Amharic characters that sound identical to the given character. The given character is always included in the result.
AmharicTransliteration::getCharEquivalents('አ'); // ["አ", "ኣ", "ዐ", "ዓ"] AmharicTransliteration::getCharEquivalents('ሰ'); // ["ሰ", "ሠ"] AmharicTransliteration::getCharEquivalents('ለ'); // ["ለ"] — no equivalents
areEquivalent(string $charA, string $charB): bool
Check whether two characters share the same sound.
AmharicTransliteration::areEquivalent('አ', 'ዓ'); // true AmharicTransliteration::areEquivalent('አ', 'ዐ'); // true AmharicTransliteration::areEquivalent('አ', 'ለ'); // false
hasVariants(string $char): bool
Check whether a character has at least one phonetically equivalent alternative.
AmharicTransliteration::hasVariants('አ'); // true AmharicTransliteration::hasVariants('ለ'); // false
Detection & utility
isAmharic(string $text): bool
Check whether a string contains at least one Amharic character.
AmharicTransliteration::isAmharic('ሰላም'); // true AmharicTransliteration::isAmharic('hello'); // false AmharicTransliteration::isAmharic('hello ሰላም'); // true
splitToChars(string $text): array
Split an Amharic (or mixed) string into individual characters using correct multi-byte handling.
AmharicTransliteration::splitToChars('ሰላም'); // ["ሰ", "ላ", "ም"]
Introspection
getMap(): array
Return the full Amharic → Latin character map as an associative array.
$map = AmharicTransliteration::getMap(); $map['ሰ']; // "se" $map['ላ']; // "la"
getEquivalenceGroups(): array
Return all defined equivalence groups. Each entry is an array of characters that share the same sound.
$groups = AmharicTransliteration::getEquivalenceGroups(); // [ // ["አ", "ኣ", "ዐ", "ዓ"], // ["ሀ", "ሐ", "ኀ"], // ["ሰ", "ሠ"], // ... // ]
Equivalence groups explained
Amharic writing has several homophone families — different characters that represent the same spoken sound. The most common ones this package handles:
| Family | Characters | Sound |
|---|---|---|
| አ / ዐ | አ ኣ ዐ ዓ |
a |
| ሀ / ሐ / ኀ | ሀ ሐ ኀ (and their vowel forms) |
h |
| ሰ / ሠ | ሰ ሠ (and their vowel forms) |
s |
| ጸ / ፀ | ጸ ፀ (and their vowel forms) |
ts |
| ጰ / ፐ | ጰ ፐ (and their vowel forms) |
p |
When you call transliterate(), all characters within a family produce the
same Latin output, so a single transliteration covers all variant spellings.
Publishing config
php artisan vendor:publish --tag=amharic-transliteration-config
Publishing the data file (if you need custom mappings)
php artisan vendor:publish --tag=amharic-transliteration-data
License
MIT — see LICENSE.
wossnap/amharic-transliteration 适用场景与选型建议
wossnap/amharic-transliteration 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 20 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「transliteration」 「laravel」 「ethiopian」 「ethiopic」 「Amharic」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 wossnap/amharic-transliteration 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wossnap/amharic-transliteration 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 wossnap/amharic-transliteration 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A simple library to sanitize text elements
i18n helpers (transliteration)
A library to convert ascii number like '3456' to geez number '፴፬፻፶፮' and vise versa.
If you ever want to convert Ethiopian Calender to any other calender system (like the Gregorian Calender) this is the right package for you. And by the way it also support Amharic date formatting and much much more.
Transliteration package for Indic scripts
Alfabank REST API integration
统计信息
- 总下载量: 20
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 30
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-28