Module: TranslationCenter::ApplicationHelper

Defined in:
app/helpers/translation_center/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#change_locale_url(locale) ⇒ Object

returns path that changes the locale



45
46
47
48
49
50
51
52
53
54
55
# File 'app/helpers/translation_center/application_helper.rb', line 45

def change_locale_url(locale)
  current_path = "#{request.protocol}#{request.host_with_port}#{request.fullpath}"
  if current_path.include?('lang_to=')
    current_path.gsub("lang_to=#{session[:lang_to]}", "lang_to=#{locale.to_s}")
  elsif current_path.include?('?')
    "#{current_path}&lang_to=#{locale.to_s}"
  else
    "#{current_path}?lang_to=#{locale.to_s}"
  end
    
end

#current_filterObject

returns the current status filter for translation keys



25
26
27
# File 'app/helpers/translation_center/application_helper.rb', line 25

def current_filter
  session[:current_filter]
end

#current_filter_is?(filter) ⇒ Boolean

returns true if the current filter is equal to the passed filter

Returns:

  • (Boolean)


30
31
32
# File 'app/helpers/translation_center/application_helper.rb', line 30

def current_filter_is?(filter)
  session[:current_filter] == filter
end

#format_date(date) ⇒ Object

returns formated date



40
41
42
# File 'app/helpers/translation_center/application_helper.rb', line 40

def format_date(date)
  date.strftime('%e %b %Y')
end

#from_langObject

get the current user the language translating from



5
6
7
# File 'app/helpers/translation_center/application_helper.rb', line 5

def from_lang
  session[:lang_from]
end

#language_direction(lang) ⇒ Object

returns the direction of the language rtl or ltr



20
21
22
# File 'app/helpers/translation_center/application_helper.rb', line 20

def language_direction(lang)
  TranslationCenter::CONFIG['lang'][lang.to_s]['direction']
end

#language_name(lang) ⇒ Object

returns the display name of the language



15
16
17
# File 'app/helpers/translation_center/application_helper.rb', line 15

def language_name(lang)
  TranslationCenter::CONFIG['lang'][lang.to_s]['name']
end

#to_langObject

get the current user the language translating to



10
11
12
# File 'app/helpers/translation_center/application_helper.rb', line 10

def to_lang
  session[:lang_to]
end

#translation_admin?Boolean

returns true if the current user can admin translations

Returns:

  • (Boolean)


35
36
37
# File 'app/helpers/translation_center/application_helper.rb', line 35

def translation_admin?
  current_user.respond_to?(:can_admin_translations?) && current_user.can_admin_translations?
end