nedka / vietnamese
The Vietnamese library for PHP.
Requires
- php: >=8.0
README
The Vietnamese toolkit for PHP.
Requirements
- PHP 8.0+.
Installation
Require this package in your composer.json
:
composer require nedka/vietnamese
composer install
Import the package:
use NEDKA\Vietnamese\Vietnamese;
Usage
Format names:
Vietnamese::formatName('ViỆt NaM')
Result: Việt Nam
Remove all accents:
Vietnamese::removeAccent('Việt Nam')
Result: Viet Nam
Convert into NCR Decimal:
Vietnamese::removeAccent('Việt Nam', 'ncr_decimal')
Result: Việt Nam
Correct wrong accent placements:
Vietnamese::fixAccent('Vịêt Nam')
Result: Việt Nam
Correct wrong cases between "i" and "y":
Vietnamese::fixIY('Thi tuổi Kỉ Tị')
Result: Thi tuổi Kỷ Tỵ
Sorting words:
Vietnamese::sortWord(['Ă', 'A', 'Â', 'À', 'Á'])
Result: ['A', 'Á', 'À', 'Ă', 'Â']
Sorting people names:
Vietnamese::sortPeopleName(['Nguyễn Văn Đảnh', 'Nguyễn VĂN Đàn', 'nguYỄn Văn Đàng', 'NGUYỄN Văn Đang', 'nguyễn anh đang'])
Result: ['Nguyễn Anh Đang', 'Nguyễn Văn Đang', 'Nguyễn Văn Đàn', 'Nguyễn Văn Đàng', 'Nguyễn Văn Đảnh']
Check a character in the Vietnamese alphabet:
Vietnamese::checkChar('w')
Result: false
Scan and detect incorrect words in Vietnamese:
Vietnamese::scanWords('Xứ Wales thắng Nga, đứng nhất bảng B')
Result: ['Wales']
Otherwise, get correct words:
Vietnamese::scanWords('Xứ Wales thắng Nga, đứng nhất bảng B', false)
Result: ['Xứ', 'thắng', 'Nga', 'đứng', 'nhất', 'bảng', 'B']
Print the way to speak a Vietnamese text string:
Vietnamese::speak('Việt Nam')
Result: i ê tờ iêt, vờ iêt viêt nặng /việt/; a mờ am, nờ am /nam/; /việt nam/
Convert number to text:
Vietnamese::numberToText(1452369)
Result: một triệu bốn trăm năm mươi hai nghìn ba trăm sáu mươi chín
License
Copyright (c) NEDKA. All rights reserved.
Licensed under the MIT License.