Module: Tests::Backend::Simple::Setup::Localization

Instance Method Summary collapse

Instance Method Details

#setupObject



26
27
28
29
30
31
# File 'lib/vendor/i18n/test/backend/simple/setup.rb', line 26

def setup
  super
  setup_datetime_translations
  setup_datetime_lambda_translations
  @old_timezone, ENV['TZ'] = ENV['TZ'], 'UTC'
end

#setup_datetime_lambda_translationsObject



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/vendor/i18n/test/backend/simple/setup.rb', line 117

def setup_datetime_lambda_translations
  backend_store_translations 'ru', {
    :date => {
      :'day_names' => lambda { |key, options|
        (options[:format] =~ /^%A/) ?
        %w(Воскресенье Понедельник Вторник Среда Четверг Пятница Суббота) :
        %w(воскресенье понедельник вторник среда четверг пятница суббота)
      },
      :'abbr_day_names' => %w(Вс Пн Вт Ср Чт Пт Сб),
      :'month_names' => lambda { |key, options|
        (options[:format] =~ /(%d|%e)(\s*)?(%B)/) ?
        %w(января февраля марта апреля мая июня июля августа сентября октября ноября декабря).unshift(nil) :
        %w(Январь Февраль Март Апрель Май Июнь Июль Август Сентябрь Октябрь Ноябрь Декабрь).unshift(nil)
      },
      :'abbr_month_names' => lambda { |key, options|
        (options[:format] =~ /(%d|%e)(\s*)(%b)/) ?
        %w(янв. февр. марта апр. мая июня июля авг. сент. окт. нояб. дек.).unshift(nil) :
        %w(янв. февр. март апр. май июнь июль авг. сент. окт. нояб. дек.).unshift(nil)
      },
    },
    :time => {
      :am => "утра",
      :pm => "вечера"
    }
  }
end

#setup_datetime_translationsObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/vendor/i18n/test/backend/simple/setup.rb', line 38

def setup_datetime_translations
  backend_store_translations :de, {
    :date => {
      :formats => {
        :default => "%d.%m.%Y",
        :short => "%d. %b",
        :long => "%d. %B %Y",
        :long_ordinalized => lambda { |date, options|
          tz = " (#{options[:timezone]})" if options[:timezone]
          "#{date.day}ter %B %Y#{tz}"
        }
      },
      :day_names => %w(Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Samstag),
      :abbr_day_names => %w(So Mo Di Mi Do Fr  Sa),
      :month_names => %w(Januar Februar März April Mai Juni Juli August September Oktober November Dezember).unshift(nil),
      :abbr_month_names => %w(Jan Feb Mar Apr Mai Jun Jul Aug Sep Okt Nov Dez).unshift(nil),
      :order => [:day, :month, :year]
    },
    :time => {
      :formats => {
        :default => "%a, %d. %b %Y %H:%M:%S %z",
        :short => "%d. %b %H:%M",
        :long => "%d. %B %Y %H:%M",
        :long_ordinalized => lambda { |date, options|
          tz = " (#{options[:timezone]})" if options[:timezone]
          "#{date.day}ter %B %Y, %H:%M Uhr#{tz}"
        }
      },
      :am => 'am',
      :pm => 'pm'
    },
    :datetime => {
      :distance_in_words => {
        :half_a_minute => 'half a minute',
        :less_than_x_seconds => {
          :one => 'less than 1 second',
          :other => 'less than {{count}} seconds'
        },
        :x_seconds => {
          :one => '1 second',
          :other => '{{count}} seconds'
        },
        :less_than_x_minutes => {
          :one => 'less than a minute',
          :other => 'less than {{count}} minutes'
        },
        :x_minutes => {
          :one => '1 minute',
          :other => '{{count}} minutes'
        },
        :about_x_hours => {
          :one => 'about 1 hour',
          :other => 'about {{count}} hours'
        },
        :x_days => {
          :one => '1 day',
          :other => '{{count}} days'
        },
        :about_x_months => {
          :one => 'about 1 month',
          :other => 'about {{count}} months'
        },
        :x_months => {
          :one => '1 month',
          :other => '{{count}} months'
        },
        :about_x_years => {
          :one => 'about 1 year',
          :other => 'about {{count}} year'
        },
        :over_x_years => {
          :one => 'over 1 year',
          :other => 'over {{count}} years'
        }
      }
    }
  }
end

#teardownObject



33
34
35
36
# File 'lib/vendor/i18n/test/backend/simple/setup.rb', line 33

def teardown
  super
  @old_timezone ? ENV['TZ'] = @old_timezone : ENV.delete('TZ')
end