定制 pointergr/greek-to-greeklish 二次开发

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

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

pointergr/greek-to-greeklish

Composer 安装命令:

composer require pointergr/greek-to-greeklish

包简介

A PHP library for converting Greek text to Greeklish (Greek words written with Latin characters)

README 文档

README

A PHP library for converting Greek text to Greeklish (Greek words written with Latin characters).

Features

  • Converts Greek text to Greeklish maintaining proper case (uppercase/lowercase)
  • Handles special Greek diphthongs (αυ, ευ, μπ, etc.)
  • Preserves non-Greek characters in the text
  • Supports all Greek characters and accents
  • Produces readable and linguistically appropriate transliterations

Installation

Install the package via composer:

composer require pointergr/greek-to-greeklish

Usage

Basic Usage

<?php

require_once 'vendor/autoload.php';

use Pointergr\GreekToGreeklish\GreekToGreeklish;

// Create a new instance
$converter = new GreekToGreeklish();

// Convert a Greek string to Greeklish
$greeklishText = $converter->convert('Καλημέρα Ελλάδα');

echo $greeklishText; // Outputs: "Kalimera Ellada"

Examples

$converter = new GreekToGreeklish();

// Single words
echo $converter->convert('Ελλάδα');      // Ellada
echo $converter->convert('Αθήνα');       // Athina
echo $converter->convert('Θεσσαλονίκη'); // Thessaloniki

// Phrases
echo $converter->convert('Καλημέρα, πώς είσαι;');  // Kalimera, pos eisai?

// Special diphthongs
echo $converter->convert('Αύριο');    // Avrio (αυ + vowel = av)
echo $converter->convert('Αυτός');    // Aftos (αυ + consonant = af)
echo $converter->convert('Εύκολο');   // Efkolo (ευ + consonant = ef)
echo $converter->convert('Ευάγγελος'); // Evangelos (ευ + vowel = ev)

// Mixed case
echo $converter->convert('ΕΛΛΑΔΑ');   // ELLADA
echo $converter->convert('Ελλάδα');   // Ellada
echo $converter->convert('ΕλΛάΔα');   // ElLaDa

Testing Functionality

The library includes a comprehensive test suite to verify correct transliteration:

$converter = new GreekToGreeklish();
$results = $converter->runTests();

echo "Tests passed: {$results['passedTests']} of {$results['totalTests']}";
echo "Success rate: {$results['successRate']}%";

// Access detailed test results
foreach ($results['results'] as $result) {
    echo "Original: {$result['original']}\n";
    echo "Expected: {$result['expected']}\n";
    echo "Actual: {$result['actual']}\n";
    echo "Passed: " . ($result['passed'] ? 'Yes' : 'No') . "\n";
    
    if (!$result['passed']) {
        echo "Difference: {$result['diff']}\n";
    }
    
    echo "\n";
}

Testing

The package comes with PHPUnit tests to ensure the conversion is working correctly:

# Install dev dependencies
composer install --dev

# Run the tests
composer test

You can also run the tests directly with PHPUnit:

./vendor/bin/phpunit

Transliteration Rules

The converter follows specific rules for transliterating Greek to Latin characters:

  1. Simple character mapping:

    • α → a, β → v, γ → g, δ → d, etc.
  2. Diphthongs:

    • αι, αί → ai
    • ει, εί → ei
    • οι, οί → oi
    • ου, ού → ou
    • ντ → nt
    • μπ → mp (within word) or b (at beginning)
    • γγ → ng
    • γκ → gk
  3. Context-sensitive substitutions:

    • αυ, ευ before vowels → av, ev
    • αυ, ευ before consonants → af, ef
    • μπ depending on position → mp or b
  4. Special cases for beginning of words:

    • θ → th (with proper capitalization)
    • χ → ch (with proper capitalization)
    • ψ → ps (with proper capitalization)

Requirements

  • PHP 7.0 or higher
  • mbstring PHP extension

License

This package is open-sourced software licensed under the MIT license.

pointergr/greek-to-greeklish 适用场景与选型建议

pointergr/greek-to-greeklish 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 02 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 pointergr/greek-to-greeklish 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 pointergr/greek-to-greeklish 我们能提供哪些服务?
定制开发 / 二次开发

基于 pointergr/greek-to-greeklish 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

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