Class: R18n::Locales::Cy

Inherits:
R18n::Locale show all
Defined in:
lib/r18n-core/locales/cy.rb

Overview

Welsh locale

Instance Attribute Summary

Attributes inherited from R18n::Locale

#code, #downcased_code, #language, #parent, #region

Instance Method Summary collapse

Methods inherited from R18n::Locale

#==, capitalize, exists?, #format_date_human, #format_date_standard, #format_float, #format_integer, #format_time, #format_time_full, #format_time_human, #format_time_standard, #initialize, #inspect, load, #localize, #ltr?, #month_abbrs, #month_standalone, #pluralize, sanitize_code, set, #strftime, #supported?, #wday_abbrs

Constructor Details

This class inherits a constructor from R18n::Locale

Instance Method Details

#format_date_full(date, year = true, *_params) ⇒ Object



43
44
45
46
47
# File 'lib/r18n-core/locales/cy.rb', line 43

def format_date_full(date, year = true, *_params)
  format = full_format
  format = year_format.sub('_', format) if year
  strftime(date, format.sub('%e', ordinalize(date.mday)))
end

#ordinalize(number) ⇒ Object



32
33
34
35
36
37
38
39
40
41
# File 'lib/r18n-core/locales/cy.rb', line 32

def ordinalize(number)
  case number % 10
  when 1 then "#{number}af"
  when 2 then "#{number}il"
  when 3, 4 then "#{number}ydd"
  when 11, 13, 14, 16, 17, 19 then "#{number}eg"
  when 21..31 then "#{number}ain"
  else "#{number}ed"
  end
end