Module: ActiveLdap::GetTextFallback::Translation

Defined in:
lib/active_ldap/get_text_fallback.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



17
18
19
# File 'lib/active_ldap/get_text_fallback.rb', line 17

def included(base)
  base.extend(self)
end

Instance Method Details

#_(msg_id) ⇒ Object



22
23
24
# File 'lib/active_ldap/get_text_fallback.rb', line 22

def _(msg_id)
  msg_id
end

#n_(arg1, arg2, arg3 = nil) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/active_ldap/get_text_fallback.rb', line 26

def n_(arg1, arg2, arg3=nil)
  if arg1.kind_of?(Array)
    msg_id = arg1[0]
    msg_id_plural = arg1[1]
    n = arg2
  else
    msg_id = arg1
    msg_id_plural = arg2
    n = arg3
  end
  n == 1 ? msg_id : msg_id_plural
end

#N_(msg_id) ⇒ Object



39
40
41
# File 'lib/active_ldap/get_text_fallback.rb', line 39

def N_(msg_id)
  msg_id
end

#Nn_(msg_id, msg_id_plural) ⇒ Object



43
44
45
# File 'lib/active_ldap/get_text_fallback.rb', line 43

def Nn_(msg_id, msg_id_plural)
  [msg_id, msg_id_plural]
end

#s_(msg_id, div = '|') ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/active_ldap/get_text_fallback.rb', line 47

def s_(msg_id, div='|')
  index = msg_id.rindex(div)
  if index
    msg_id[(index + 1)..-1]
  else
    msg_id
  end
end