jurchiks / numbers2words
可以将数字(和货币)转换成文字!
2.9.0
2022-03-14 13:16 UTC
Requires
- php: >=7.1
README
这是一个通用库,用于将数字转换为文字,例如用于法律文件和账单。
支持的语言(ISO 639-1 语言代码)
- 英语 (
en
) - 爱沙尼亚语 (
et
) - 拉脱维亚语 (
lv
) - 立陶宛语 (
lt
) - 俄语 (
ru
) - 西班牙语 (
es
) - 意大利语 (
it
) - 波兰语 (
pl
)
支持货币(ISO 4217 货币代码)
- 英镑 (
GBP
) - 欧元 (
EUR
) - 拉脱维亚拉特 (
LVL
) - 立陶宛立特 (
LTL
) - 俄罗斯卢布 (
RUR
) - 美元 (
USD
) - 波兰兹罗提 (
PLN
) - 坦桑尼亚先令 (
TZS
)
安装
composer require jurchiks/numbers2words
使用
use js\tools\numbers2words\Speller; Speller::spellNumber(123, Speller::LANGUAGE_RUSSIAN); // output: сто двадцать три Speller::spellCurrency(123, Speller::LANGUAGE_ENGLISH, Speller::CURRENCY_EURO, false); // output: one hundred twenty three euro Speller::spellCurrency(123, Speller::LANGUAGE_ENGLISH, Speller::CURRENCY_EURO); // output: one hundred twenty three euro and 0 cents Speller::spellCurrency(123.45, Speller::LANGUAGE_ENGLISH, Speller::CURRENCY_EURO, true, true); // output: one hundred twenty three euro and forty five cents Speller::spellCurrencyShort(123.45, Speller::LANGUAGE_ENGLISH, Speller::CURRENCY_EURO); // output: one hundred twenty three EUR 45/100
Twig
此库有一个可用于Twig的扩展: jurchiks/numbers2words_twig