Laravel Zawgyi <-> Unicode Package
11,007
7
3
Package Data
Maintainer Username: TintNaingWinn
Maintainer Contact: amigo.k8@gmail.com (Tint Naing Win)
Package Create Date: 2017-08-09
Package Last Update: 2024-04-27
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-12-15 15:03:59
Package Statistics
Total Downloads: 11,007
Monthly Downloads: 106
Daily Downloads: 0
Total Stars: 7
Total Watchers: 3
Total Forks: 2
Total Open Issues: 0

Laravel MyanFont

License

Installation

You can install this package via composer using this command:

composer require tintnaingwin/myanfont

The package will automatically register itself.

You can publish the config-file with:

php artisan vendor:publish --provider="Tintnaingwin\MyanFont\MyanFontServiceProvider"

This is the contents of the published config file:

return [
    
    'myanmar_tools' => [
        /*
         * If enabled, will use Myanmar-Tools.
         */
        'enabled' => false,

        /*
         * If over-predicting Zawgyi is bad (e.g., when conversion will take place automatically), set a high threshold like 0.95.
         * This threshold guarantees that fewer than 1% of Unicode strings will be wrongly flagged.
         */
        'zawgyi_score' => 0.95,


        /*
         * If under-predicting Zawgyi is bad (e.g., when a human gets to evaluate the result), set a low threshold like 0.05.
         * This threshold guarantees that fewer than 1% of Zawgyi strings will go undetected.
         */
        'unicode_score' => 0.05,
    ],
    
];

Usage

Using the facade

You can choose to detect the font Myanmar Toots or Regular Expression. By default, using Regular Expression. You can change at config file.

  • Unicode to Zawgyi
// using myanmar tools
MyanFont::uni2zg('ဥုံတလဲလဲဖွတလဲလဲ', ture); // ဥဳံတလဲလဲဖြတလဲလဲ

// using regular expression
MyanFont::uni2zg('ဥုံတလဲလဲဖွတလဲလဲ', false); // ဥဳံတလဲလဲဖြတလဲလဲ

// By Default (regular expression)
MyanFont::uni2zg('ဥုံတလဲလဲဖွတလဲလဲ'); // ဥဳံတလဲလဲဖြတလဲလဲ
  • Zawgyi to Unicode
// using myanmar tools
MyanFont::zg2uni('ဥဳံတလဲလဲဖြတလဲလဲ', ture); // ဥုံတလဲလဲဖွတလဲလဲ

// using regular expression
MyanFont::zg2uni('ဥဳံတလဲလဲဖြတလဲလဲ', false); // ဥုံတလဲလဲဖွတလဲလဲ

// By Default (regular expression)
MyanFont::zg2uni('ဥဳံတလဲလဲဖြတလဲလဲ'); // ဥုံတလဲလဲဖွတလဲလဲ
  • Detect Font
// using myanmar tools
MyanFont::isZgOrUni('ချယ်ရီ', ture); // output - unicode

// using regular expression
MyanFont::isZgOrUni('ခ်ယ္ရီ', false); // output - zawgyi

// By Default (regular expression)
MyanFont::isZgOrUni('ချယ်ရီ'); // output - unicode

Using with Helpers

  • Unicode to Zawgyi
// using myanmar tools
uni2zg('ဥုံတလဲလဲဖွတလဲလဲ', ture); // ဥဳံတလဲလဲဖြတလဲလဲ

// By Default (regular expression)
uni2zg('ဥုံတလဲလဲဖွတလဲလဲ'); // ဥဳံတလဲလဲဖြတလဲလဲ
  • Zawgyi to Unicode
// using myanmar tools
zg2uni('ဥဳံတလဲလဲဖြတလဲလဲ', true); // ဥုံတလဲလဲဖွတလဲလဲ

// By Default (regular expression)
zg2uni('ဥဳံတလဲလဲဖြတလဲလဲ'); // ဥုံတလဲလဲဖွတလဲလဲ
  • Detect Font
// using myanmar tools
isZgOrUni('ချယ်ရီ', true); // output - unicode

// By Default (regular expression)
isZgOrUni('ခ်ယ္ရီ'); // output - zawgyi

Testing

You can run the tests with:

vendor/bin/phpunit

Credits

License

The MIT License (MIT). Please see License File for more information.