数字到英文单词转换 Rails [英] Number to English Word Conversion Rails
本文介绍了数字到英文单词转换 Rails的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有谁知道在rails中将数字转换为英文数字单词的方法吗?
Anybody knows the method to convert the numericals to english number words in rails?
我找到了一些 Ruby 脚本来将数字转换为对应单词的英文单词.
I found some Ruby scripts to convert numbericals to english words for corresponding words.
我觉得不是用 ruby 写脚本,而是直接函数可用.
Instead of writing a script in ruby, i feel that direct function is available.
例如.1 -> 一,2 -> 两个.
Eg. 1 -> One, 2 -> Two.
推荐答案
不,你必须自己写一个函数.最接近你想要的东西是 number_to_human
,但这不会将 1
转换为 One
.
No, you have to write a function yourself. The closest thing to what you want is number_to_human
, but that does not convert 1
to One
.
以下是一些可能有用的网址:
Here are some URLs that may be helpful:
- http://codesnippets.joyent.com/posts/show/447
- http://raveendran.wordpress.com/2009/05/29/ruby-convert-number-to-english-word/
- http://deveiate.org/projects/Linguistics/
这篇关于数字到英文单词转换 Rails的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文