Class: GetText::Tools::MsgInit::CLDRPluralsConverter

Inherits:
Object
  • Object
show all
Defined in:
lib/gettext/tools/msginit.rb

Instance Method Summary collapse

Constructor Details

#initialize(language) ⇒ CLDRPluralsConverter

Returns a new instance of CLDRPluralsConverter.



374
375
376
377
# File 'lib/gettext/tools/msginit.rb', line 374

def initialize(language)
  @language = language

end

Instance Method Details

#convertObject



379
380
381
382
383
384
385
386
387
388
389
390
391
# File 'lib/gettext/tools/msginit.rb', line 379

def convert
  n_plurals = nil
  expression = nil
  if defined?(Datasets::CLDRPlurals)
    plurals = Datasets::CLDRPlurals.new
    plurals.each do |locale|
      next unless locale.name == @language
      n_plurals, expression = convert_plural_rules(locale.rules)
      break
    end
  end
  "nplurals=#{n_plurals}; plural=#{expression};"
end