Sha256: 2836868cbbcd59d24f9737d4a2263242ae342e6f320355a41ee05ef0500976bc

Contents?: true

Size: 879 Bytes

Versions: 1

Compression:

Stored size: 879 Bytes

Contents

# encoding: UTF-8

# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0

class String
  def localize(locale = TwitterCldr.get_locale)
    TwitterCldr::LocalizedString.new(self, locale)
  end
end

module TwitterCldr
  class LocalizedString < LocalizedObject

    # Uses wrapped string object as a format specification and returns the result of applying it to +args+ (see
    # +TwitterCldr::Utils.interpolate+ method for interpolation syntax).
    #
    # If +args+ is a Hash than pluralization is performed before interpolation (see +PluralFormatter+ class for
    # pluralization specification).
    #
    def %(args)
      pluralized = args.is_a?(Hash) ? @formatter.format(@base_obj, args) : @base_obj
      TwitterCldr::Utils.interpolate(pluralized, args)
    end

    def formatter_const
      TwitterCldr::Formatters::PluralFormatter
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
twitter_cldr-1.1.0 lib/ext/strings/string.rb