Methods

Files

FastGettext::Translation

this module should be included Responsibility:

- direct translation queries to the current repository
- handle untranslated values
- understand / enforce namespaces
- decide which plural form is used

Public Instance Methods

N_(translate) click to toggle source

tell gettext: this string need translation (will be found during parsing)

# File lib/fast_gettext/translation.rb, line 44
def N_(translate)
  translate
end
Nn_(*keys) click to toggle source

tell gettext: this string need translation (will be found during parsing)

# File lib/fast_gettext/translation.rb, line 49
def Nn_(*keys)
  keys
end
_(key) click to toggle source
# File lib/fast_gettext/translation.rb, line 20
def _(key)
  FastGettext.cached_find(key) or key
end
n_(*keys) click to toggle source

translate pluralized

some languages have up to 4 plural forms...
n_(singular, plural, plural form 2, ..., count)
n_('apple','apples',3)
# File lib/fast_gettext/translation.rb, line 28
def n_(*keys)
  count = keys.pop
  translations = FastGettext.cached_plural_find *keys
  selected = FastGettext.pluralisation_rule.call(count)
  selected = selected ? 1 : 0 unless selected.is_a? Numeric #convert booleans to numbers
  translations[selected] || keys[selected] || keys.last
end
ns_(*args) click to toggle source
# File lib/fast_gettext/translation.rb, line 53
def ns_(*args)
  n_(*args).split(NAMESPACE_SEPERATOR).last
end
s_(key,seperator=nil) click to toggle source

translate, but discard namespace if nothing was found

Car|Tire -> Tire if no translation could be found
# File lib/fast_gettext/translation.rb, line 38
def s_(key,seperator=nil)
  translation = FastGettext.cached_find(key) and return translation
  key.split(seperator||NAMESPACE_SEPERATOR).last
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.