Sha256: 466a1bdd42c25a49a485966bf2985ee9a725e361d06adafcab89c1dfb1dc46b8

Contents?: true

Size: 876 Bytes

Versions: 12

Compression:

Stored size: 876 Bytes

Contents

#coding: utf-8

def _(str)
  thread = Thread.current
  thread_hayabusa = thread[:hayabusa]
  raise "Could not register Hayabusa-data." if !thread_hayabusa
  hb = thread_hayabusa[:hb]
  raise "Could not register Hayabusa." if !hb
  raise "'gettext' not enabled for Hayabusa." if !hb.gettext
  
  session = thread_hayabusa[:session].sess_data if thread_hayabusa[:session]
  locale = nil
  
  if !thread[:locale].to_s.empty?
    locale = thread[:locale]
  elsif session and !session[:locale].to_s.strip.empty?
    locale = session[:locale]
  elsif hb and !hb.config[:locale_default].to_s.strip.empty?
    session[:locale] = hb.config[:locale_default] if session
    locale = hb.config[:locale_default]
  elsif !session and !hb
    return str
  else
    raise "No locale set for session and ':locale_default' not set in config."
  end
  
  return hb.gettext.trans(locale, str)
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
hayabusa-0.0.30 lib/kernel_ext/gettext_methods.rb
hayabusa-0.0.29 lib/kernel_ext/gettext_methods.rb
hayabusa-0.0.28 lib/kernel_ext/gettext_methods.rb
hayabusa-0.0.25 lib/kernel_ext/gettext_methods.rb
hayabusa-0.0.24 lib/kernel_ext/gettext_methods.rb
hayabusa-0.0.23 lib/kernel_ext/gettext_methods.rb
hayabusa-0.0.22 lib/kernel_ext/gettext_methods.rb
hayabusa-0.0.20 lib/kernel_ext/gettext_methods.rb
hayabusa-0.0.19 lib/kernel_ext/gettext_methods.rb
hayabusa-0.0.18 lib/kernel_ext/gettext_methods.rb
hayabusa-0.0.17 lib/kernel_ext/gettext_methods.rb
hayabusa-0.0.16 lib/kernel_ext/gettext_methods.rb