Module: TT::BuiltinRules

Extended by:
BuiltinRules
Included in:
BuiltinRules
Defined in:
lib/t_t/builtin_rules.rb

Instance Method Summary collapse

Instance Method Details

#de__gender(f) ⇒ Object

this lambda generate default translation for masculine form & add exceptions for feminine & neuter genders ie

new:
  base: "Neuen %{r} hinzufügen"    -> "Neuen Benutzer anlegen"
  company: "Neues %{r} hinzufügen" -> "Neues Unternehmen anlegen"
  role: "Neue %{r} hinzufügen"     -> "Neue Rolle hinzufügen"


26
27
28
29
30
31
# File 'lib/t_t/builtin_rules.rb', line 26

def de__gender(f)
  f.for(:de) do |l|
    l.rule(:feminine) { |_, a_meta, _| a_meta }
    l.rule(:neuter)   { |_, a_meta, _| a_meta }
  end
end

#en__an(f) ⇒ Object

The indefinite article a (before a consonant sound) or an (before a vowel sound) is used only with singular, countable nouns.



7
8
9
10
11
# File 'lib/t_t/builtin_rules.rb', line 7

def en__an(f)
  f.for(:en) do |l|
    l.rule(:an) { |_, a_meta, _| a_meta }
  end
end

#ru__accuse(f) ⇒ Object

To get a correct translation in Russian you need to set the proper ending for object by using ‘Винительный падеж - Кого? Что?` “Создать Компанию(кого?) & Cоздать Сектор(что?)” for `что?` we can use the resource name, for `кого?` - need to provide a separated key



37
38
39
40
41
42
43
# File 'lib/t_t/builtin_rules.rb', line 37

def ru__accuse(f)
  f.for(:ru) do |l|
    l.rule(:accuse) do |base, _, r_meta|
      r_meta.inject(base) { |str, (k, t)| str.gsub("%{#{k}}", t) }
    end
  end
end