bahttext
Version:
Change number to Thai pronunciation string
98 lines (80 loc) • 7.22 kB
Markdown
# bahttext
[](https://www.npmjs.com/package/bahttext)
[](https://www.npmjs.com/package/bahttext)
[](http://opensource.org/licenses/MIT)
[](https://packagephobia.com/result?p=bahttext)
[](https://github.com/semantic-release/semantic-release) [](https://greenkeeper.io/)
[](https://codecov.io/github/jojoee/bahttext)
[](https://dashboard.stryker-mutator.io/reports/github.com/jojoee/bahttext/master)
[](https://github.com/jojoee/bahttext/actions/workflows/continuous-integration.yml)
[](https://github.com/jojoee/bahttext/actions/workflows/release.yml)
[](https://github.com/jojoee/bahttext/actions/workflows/runnable.yml)
[](https://github.com/jojoee/bahttext/actions/workflows/runnable-old-node.yml)
Only `TH` and `EN` languages are maintained, the rest is auto-generated by ChatGPT API. Language:
[ไทย](https://github.com/jojoee/bahttext/blob/master/README.md),
[English](https://github.com/jojoee/bahttext/blob/master/README-en.md),
[中国大陆](https://github.com/jojoee/bahttext/blob/master/doc/README-cn.md),
[대한민국](https://github.com/jojoee/bahttext/blob/master/doc/README-kr.md),
[Việt Nam](https://github.com/jojoee/bahttext/blob/master/doc/README-vn.md),
[日本](https://github.com/jojoee/bahttext/blob/master/doc/README-jp.md),
[Россия](https://github.com/jojoee/bahttext/blob/master/doc/README-ru.md),
[Español](https://github.com/jojoee/bahttext/blob/master/doc/README-la.md),
[Français](https://github.com/jojoee/bahttext/blob/master/doc/README-fr.md)
เปลี่ยนตัวเลข เป็นคำอ่านภาษาไทย,
โมดูลตัวนี้ได้ทำการทดสอบกับ [Google Sheets BAHTTEXT function](https://support.google.com/docs/answer/9982303?hl=en), [Demo page](https://jojoee.github.io/bahttext/)
เรียบร้อยแล้ว
## ติดตั้ง
```
// CommonJS
npm install bahttext
const { bahttext } = require('bahttext')
// Bower
bower install bahttext
<script src="bower_components/bahttext/src/index.js"></script>
// githack
<script src="https://raw.githack.com/jojoee/bahttext/master/src/index.js"></script>
// ES6
npm install bahttext
import { bahttext } from "bahttext"
```
## ตัวอย่างการใช้งาน
```javascript
bahttext(8.00) // แปดบาทถ้วน
bahttext(5678.00) // ห้าพันหกร้อยเจ็ดสิบแปดบาทถ้วน
bahttext(63147.89) // หกหมื่นสามพันหนึ่งร้อยสี่สิบเจ็ดบาทแปดสิบเก้าสตางค์
bahttext(51000001.00) // ห้าสิบเอ็ดล้านหนึ่งบาทถ้วน
bahttext(317.10) // สามร้อยสิบเจ็ดบาทสิบสตางค์
bahttext(422.26) // สี่ร้อยยี่สิบสองบาทยี่สิบหกสตางค์
bahttext(11.11) // สิบเอ็ดบาทสิบเอ็ดสตางค์
bahttext(191415.11) // หนึ่งแสนเก้าหมื่นหนึ่งพันสี่ร้อยสิบห้าบาทสิบเอ็ดสตางค์
bahttext(1.01) // หนึ่งบาทหนึ่งสตางค์
bahttext(5678.46) // ห้าพันหกร้อยเจ็ดสิบแปดบาทสี่สิบหกสตางค์
bahttext(0.67) // หกสิบเจ็ดสตางค์
bahttext(-3.00) // ลบสามบาทถ้วน
bahttext(-232.00) // ลบสองร้อยสามสิบสองบาทถ้วน
bahttext(-44444.00) // ลบสี่หมื่นสี่พันสี่ร้อยสี่สิบสี่บาทถ้วน
bahttext(-5678934.00) // ลบห้าล้านหกแสนเจ็ดหมื่นแปดพันเก้าร้อยสามสิบสี่บาทถ้วน
bahttext(-201.00) // ลบสองร้อยหนึ่งบาทถ้วน
bahttext(-317.10) // ลบสามร้อยสิบเจ็ดบาทสิบสตางค์
bahttext(-5723.00) // ลบห้าพันเจ็ดร้อยยี่สิบสามบาทถ้วน
bahttext(-11.00) // ลบสิบเอ็ดบาทถ้วน
bahttext(-45621.21) // ลบสี่หมื่นห้าพันหกร้อยยี่สิบเอ็ดบาทยี่สิบเอ็ดสตางค์
bahttext(-191415.11) // ลบหนึ่งแสนเก้าหมื่นหนึ่งพันสี่ร้อยสิบห้าบาทสิบเอ็ดสตางค์
bahttext(-282622.22) // ลบสองแสนแปดหมื่นสองพันหกร้อยยี่สิบสองบาทยี่สิบสองสตางค์
bahttext(-1.04) // ลบหนึ่งบาทสี่สตางค์
bahttext(-574.45) // ลบห้าร้อยเจ็ดสิบสี่บาทสี่สิบห้าสตางค์
bahttext(-345.23) // ลบสามร้อยสี่สิบห้าบาทยี่สิบสามสตางค์
bahttext(-0.20) // ลบยี่สิบสตางค์
```
## ฟีเจอร์
- สามารถใช้งานได้ทุก เบราว์เซอร์
- สามารถใช้งานได้ตั้งแต่ Node.js version 6+
- 0 Dependencies
- หน้าตัวอย่างการใช้งาน
- สนับสนุนการใช้งานกับตัวเลขติดลบ
## ภาษาอื่นๆ
- Python: [jojoee/pybaht](https://github.com/jojoee/pybaht)
## อ้างอิง
- [Google Sheets BAHTTEXT function](https://support.google.com/docs/answer/9982303?hl=en)
- [Microsoft Office's BAHTTEXT function](https://support.office.com/en-us/article/BAHTTEXT-function-5ba4d0b4-abd3-4325-8d22-7a92d59aab9c)
- แรงบัลดาลใจจาก [earthchie/BAHTTEXT.js](https://github.com/earthchie/BAHTTEXT.js)