module MessageFormat
Turns this:
[ "You have ", [ "numBananas", "plural", 0, { "=0": [ "no bananas" ], "one": [ "a banana" ], "other": [ [ '#' ], " bananas" ] } ], " for sale." ]
into this:
format({ numBananas:0 }) "You have no bananas for sale."
Turns this:
`You have { numBananas, plural,
=0 {no bananas}
one {a banana}
other {# bananas}
} for sale`
into this:
[ "You have ", [ "numBananas", "plural", 0, { "=0": [ "no bananas" ], "one": [ "a banana" ], "other": [ [ '#' ], " bananas" ] } ], " for sale." ]
Constants
- VERSION
Public Class Methods
format_message( pattern, args=nil, locale=nil )
click to toggle source
# File lib/message_format.rb, line 29 def format_message ( pattern, args=nil, locale=nil ) locale ||= TwitterCldr.locale Interpreter.interpret( Parser.parse(pattern), { :locale => locale.to_sym } ).call(args) end
new( pattern, locale=nil )
click to toggle source
# File lib/message_format.rb, line 25 def new ( pattern, locale=nil ) MessageFormat.new(pattern, locale) end