lib/gettext/textdomain_manager.rb
# This function is similar to the get_singluar_message function 
# as it finds the message catalogs in the same way. 
# But it takes two extra arguments for plural form.
# The msgid parameter must contain the singular form of the string to be converted. 
# It is also used as the key for the search in the catalog. 
# The msgid_plural parameter is the plural form. 
# The parameter n is used to determine the plural form. 
# If no message catalog is found msgid1 is returned if n == 1, otherwise msgid2. 
# And if msgid includes "div", it returns a last part of msgid separeted "div".
#
# * msgid: the singular form with "div". (e.g. "Special|An apple", "An apple")
# * msgid_plural: the plural form. (e.g. "%{num} Apples")
# * n: a number used to determine the plural form.
# * div: the separator. Default is "|".
# * Returns: the localized text which key is msgid_plural if n is plural(follow plural-rule) or msgid.
#   "plural-rule" is defined in po-file.
#
# or
#
# * [msgid, msgid_plural] : msgid and msgid_plural an Array
# * n: a number used to determine the plural form.
# * div: the separator. Default is "|".
This function is similar to the get_singluar_message function
as it finds the message catalogs in the same way.
But it takes two extra arguments for plural form.
The msgid parameter must contain the singular form of the string to be converted.
It is also used as the key for the search in the catalog.
The msgid_plural parameter is the plural form.
The parameter n is used to determine the plural form.
If no message catalog is found msgid1 is returned if n == 1, otherwise msgid2.
And if msgid includes "div", it returns a last part of msgid separeted "div".

the singular form with "div".
msgid_plural: the plural form.
n: a number used to determine the plural form.
div: the separator. Default is "|".
Returns: the localized text which key is msgid_plural if n is plural(follow plural-rule) or msgid.
"plural-rule" is defined in po-file.

or

[msgid, msgid_plural] : msgid and msgid_plural an Array
n: a number used to determine the plural form.
div: the separator. Default is "|".
This function is similar to the get_singluar_message function as it finds the message catalogs in the same way . But it takes two extra arguments for plural form . The msgid parameter must contain the singular form of the string to be converted . It is also used as the key for the search in the catalog . The msgid_plural parameter is the plural form . The parameter n is used to determine the plural form . If no message catalog is found msgid1 is returned if n == 1 otherwise msgid2 . And if msgid includes " div " it returns a last part of msgid separeted " div " . the singular form with " div " . msgid_plural : the plural form . n : a number used to determine the plural form . div : the separator . Default is " | " . Returns : the localized text which key is msgid_plural if n is plural ( follow plural - rule ) or msgid . " plural - rule " is defined in po - file . or [ msgid msgid_plural ] : msgid and msgid_plural an Array n : a number used to determine the plural form . div : the separator . Default is " | " .
def translate_plural_message(klass, arg1, arg2, arg3 = "|", arg4 = "|")
      lang = Locale.candidates(:supported_language_tags => @supported_language_tags,
                               :type => :posix)[0]
      if arg1.kind_of?(Array)
        msgid = arg1[0]
        msgid_plural = arg1[1]
        n = arg2
        if arg3 and arg3.kind_of? Numeric
          raise ArgumentError, _("3rd parmeter is wrong: value = %{number}") % {:number => arg3}
        end
        div = arg3
      else
        msgid = arg1
        msgid_plural = arg2
        n = arg3
        div = arg4
      end
      msgs = nil
      ClassInfo.related_classes(klass, @@gettext_classes).each do |target|
        msgs = nil
        self.class.get(target).textdomains.each do |textdomain|
          msgs = textdomain.translate_plural_message(lang, msgid, msgid_plural)
          break if msgs
        end
        break if msgs
      end
      msgs = [[msgid, msgid_plural], "n != 1"] unless msgs
      msgstrs = msgs[0]
      if div and msgstrs[0] == msgid and index = msgstrs[0].rindex(div)
        msgstrs[0] = msgstrs[0][(index + 1)..-1]
      end
      plural = eval(msgs[1])
      return msgstrs[plural] if plural.kind_of?(Numeric)
      return plural ? msgstrs[1] : msgstrs[0]
    end
def translate_plural_message ( klass , arg1 , arg2 , arg3 = "|" , arg4 = "|" ) lang = Locale . candidates ( :supported_language_tags => @supported_language_tags , :type => :posix ) [ 0 ] if arg1 . kind_of? ( Array ) msgid = arg1 [ 0 ] msgid_plural = arg1 [ 1 ] n = arg2 if arg3 and arg3 . kind_of? Numeric raise ArgumentError , _ ( "3rd parmeter is wrong: value = %{number}" ) % { :number => arg3 } end div = arg3 else msgid = arg1 msgid_plural = arg2 n = arg3 div = arg4 end msgs = nil ClassInfo . related_classes ( klass , @@gettext_classes ) . each do | target | msgs = nil self . class . get ( target ) . textdomains . each do | textdomain | msgs = textdomain . translate_plural_message ( lang , msgid , msgid_plural ) break if msgs end break if msgs end msgs = [ [ msgid , msgid_plural ] , "n != 1" ] unless msgs msgstrs = msgs [ 0 ] if div and msgstrs [ 0 ] == msgid and index = msgstrs [ 0 ] . rindex ( div ) msgstrs [ 0 ] = msgstrs [ 0 ] [ ( index + 1 ) .. - 1 ] end plural = eval ( msgs [ 1 ] ) return msgstrs [ plural ] if plural . kind_of? ( Numeric ) return plural ? msgstrs [ 1 ] : msgstrs [ 0 ] end
This function is similar to the get_singluar_message function
as it finds the message catalogs in the same way.
This function is similar to the get_singluar_message function as it finds the message catalogs in the same way .
# parse arguments # Find messages from related classes. # If not found, return msgid. # Return the singular or plural message.
klass
<not_specific>
arg1
<not_specific>
arg2
<not_specific>
arg3
<not_specific>
arg4
<not_specific>