Module: Zena::Use::I18n::ViewMethods

Includes:
RubyLess, FormatDate
Defined in:
lib/zena/use/i18n.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from FormatDate

#full_date, #long_date, #long_time, #short_date, #short_time, #tformat_date

Class Method Details

.included(base) ⇒ Object



211
212
213
# File 'lib/zena/use/i18n.rb', line 211

def self.included(base)
  base.send(:alias_method_chain, :will_paginate, :i18n) if base.respond_to?(:will_paginate)
end

Instance Method Details

#_(str) ⇒ Object

translation of static text using gettext FIXME: I do not know why this is needed in order to have <%= _(‘blah’) %> find the translations on some servers



224
225
226
# File 'lib/zena/use/i18n.rb', line 224

def _(str)
  ApplicationController.send(:_, str)
end

show language selector



237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/zena/use/i18n.rb', line 237

def lang_links(opts={})
  if opts[:wrap]
    tag_in  = "<#{opts[:wrap]}>"
    tag_out = "</#{opts[:wrap]}>"
  else
    tag_in = tag_out = ''
  end
  res = []
  visitor.site.lang_list.each do |l|
    if l == visitor.lang
      if opts[:wrap]
        res << "<#{opts[:wrap]} class='on'>#{l}" + tag_out
      else
        res << "<em>#{l}</em>"
      end
    else
      if params[:controller] == 'nodes'
        res << tag_in + "<a href='#{zen_path(@node, :lang => l)}'>#{l}</a>" + tag_out
      else
        res << tag_in + link_to(l, params.merge(:lang => l)) + tag_out
      end
    end
  end
  res.join(opts[:join] || '')
end

#load_dictionary(node_id, static = nil) ⇒ Object



232
233
234
# File 'lib/zena/use/i18n.rb', line 232

def load_dictionary(node_id, static=nil)
  Zena::Use::I18n::TranslationDict.new(node_id, static)
end

#trans(str) ⇒ Object



228
229
230
# File 'lib/zena/use/i18n.rb', line 228

def trans(str)
  ApplicationController.send(:_, str)
end

#will_paginate_with_i18n(collection, options = {}) ⇒ Object

Enable translations for will_paginate



218
219
220
# File 'lib/zena/use/i18n.rb', line 218

def will_paginate_with_i18n(collection, options = {})
  will_paginate_without_i18n(collection, options.merge(:prev_label => _('img_prev_page'), :next_label => _('img_next_page')))
end