Skip to content

Instantly share code, notes, and snippets.

@camertron
Last active December 23, 2015 18:19
Show Gist options
  • Select an option

  • Save camertron/6674851 to your computer and use it in GitHub Desktop.

Select an option

Save camertron/6674851 to your computer and use it in GitHub Desktop.
Rule-based Number Formatting with twitter-cldr-rb
# clone twitter-cldr-rb, change to rbnf branch
# Note: There are probably bugs with this implementation, and the function names will
# likely change (underscores instead of camel case, for example). Use only with the
# understanding that you will probably have to change your code later.
#
# Any and all questions/comments always appreciated!
require 'twitter_cldr/formatters/numbers/rbnf/en'
puts TwitterCldr::Formatters::RuleBasedNumberFormatter::English.renderDigitsOrdinal(123)
# Alternatively, this also works:
TwitterCldr::Formatters::RuleBasedNumberFormatter.for_locale(:en).renderDigitsOrdinal(123)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment