This repository has been archived by the owner on Mar 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
92 lines (65 loc) · 2.18 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
= Yesno
Yesno is a simple utility for boolean case.
"yesno" is a simple aid for the Boolean case. "yesno" transforms the answers to true / false in various interpretations possible (yes / no, male / female, active / inactive). To use I18n translations and is provided with translations in Italian, English and French.
== Install
gem install yesno
rails generate yesno:install
== standard implementation
=== Example:
if @article.active is false
yesno(@article.active) -> "false"
yesno(@article.active, :type => "atc") -> "inactive"
if @person.sex is true
# yesno(@person.sex, :type => "mf") -> "male"
## yesno(@person.sex, :type => "mf", :pluralize => true) -> "man"
the options are
:type => "tipology"
:female => true/false
:pluralize => true/false
the types are
"default" (true/false)
"yn" (yes/no)
"mf" (male/female)
"act" (active/inactive)
== fast implementation
Fyesno is a more fast implementation of yesno.
Fyesno" solves the conversion with a single "if" using the options to address directly the translation.
# fyesno(to_validate, type, option)
where default type is "default" and default option is "ms".
"option" is a string containing the two letters to this standard:
"ms" masculine singular
"mp" masculine plural
"fs" feminine singular
"fp" feminine plural
=== Example
if @var.test is true
# fyesno(@var.test) -> "true"
# fyesno(@var.test, "mf", "mp") -> "man"
# fyesno(@var.test, "act", "fp") -> "actives"
== extend the types
To add new features just edit the file yesno.#{lang}.yml and add new implementations:
it:
yesno:
default:
smt: "vero"
smf: "falso"
sft: "vera"
sff: "falsa"
pmt: "veri"
pmf: "falsi"
pft: "vere"
pff: "false"
yn:
smt: "si"
smf: "no"
ecc.....
- the type of translation is the third indentation
- the translation is the fourth indentation
- the name of the traslation (smt, smf, ecc.) is the declination.
smt single male true
smf single male false
..
pff pural female false
With this simple rule is possible to implement new uses
This project rocks and uses MIT-LICENSE.
email me if you have new implementations or translations