i18n-inflector 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +23 -0
- data/Gemfile +10 -0
- data/LGPL-LICENSE +169 -0
- data/Manifest.txt +20 -0
- data/README.textile +27 -0
- data/Rakefile +100 -0
- data/docs/COPYING +61 -0
- data/docs/HISTORY +6 -0
- data/docs/LEGAL +11 -0
- data/docs/LGPL-LICENSE +169 -0
- data/docs/README +101 -0
- data/docs/rdoc.css +20 -0
- data/lib/i18n-inflector/inflector.rb +652 -0
- data/lib/i18n-inflector/long_comments.rb +399 -0
- data/lib/i18n-inflector/shortcuts.rb +62 -0
- data/lib/i18n-inflector.rb +5 -0
- data/test/all.rb +8 -0
- data/test/backend/inflection_test.rb +249 -0
- data/test/run_all.rb +21 -0
- data/test/test_helper.rb +32 -0
- data.tar.gz.sig +0 -0
- metadata +156 -0
- metadata.gz.sig +2 -0
data/docs/README
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
= Simple Inflector for I18n
|
2
|
+
|
3
|
+
<b>i18n-inflector version <tt>1.0.0</tt></b> (<b><tt>Aropsaid</tt></b>)
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
* http://rubygems.org/gems/i18n-inflector
|
8
|
+
* https://github.com/siefca/i18n-inflector/tree
|
9
|
+
* mailto:pw@gnu.org
|
10
|
+
|
11
|
+
== Description
|
12
|
+
|
13
|
+
This backend module for Ruby's I18n overwrites the Simple backend
|
14
|
+
translate method so that it will interpolate additional inflection
|
15
|
+
tokens present in translations. These tokens may appear in *patterns*
|
16
|
+
which are contained within <tt>@{</tt> and <tt>}</tt>
|
17
|
+
symbols.
|
18
|
+
|
19
|
+
You can choose different kinds (gender, title, person, time, author, etc.)
|
20
|
+
of tokens to group them in a meaningful, semantical sets. That means you can
|
21
|
+
apply Inflector to do simple inflection by a gender or a person, when some
|
22
|
+
language requires it.
|
23
|
+
|
24
|
+
To achieve similar functionality lambdas can be used but there might be
|
25
|
+
some areas of appliance that including proc objects in translations
|
26
|
+
is prohibited.
|
27
|
+
|
28
|
+
If you have a troop of happy translators that shouldn't have the
|
29
|
+
ability to execute any code yet you need some simple inflection
|
30
|
+
then you can make use of this module.
|
31
|
+
|
32
|
+
== Synopsis
|
33
|
+
|
34
|
+
require 'i18n-inflector'
|
35
|
+
i18n.translate('welcome')
|
36
|
+
|
37
|
+
Detailed example:
|
38
|
+
|
39
|
+
I18n.locale = :en
|
40
|
+
I18n.backend.store_translations 'en', :i18n => { :inflections => {
|
41
|
+
:gender => {
|
42
|
+
:f => 'female',
|
43
|
+
:m => 'male',
|
44
|
+
:n => 'neuter',
|
45
|
+
:default => 'n' }}}
|
46
|
+
|
47
|
+
I18n.backend.store_translations 'en', 'welcome' => 'Dear @{f:Lady|m:Sir|n:You|All}'
|
48
|
+
|
49
|
+
I18n.t('welcome')
|
50
|
+
# => "Dear You"
|
51
|
+
|
52
|
+
I18n.t('welcome', :gender => :male)
|
53
|
+
# => "Dear Sir"
|
54
|
+
|
55
|
+
I18n.t('welcome', :gender => :unknown)
|
56
|
+
# => "Dear All"
|
57
|
+
|
58
|
+
I18n.t('welcome', :gender => nil)
|
59
|
+
# => "Dear All"
|
60
|
+
|
61
|
+
See I18n::Backend::Inflector module documentation for more examples and definitions.
|
62
|
+
|
63
|
+
== Requirements
|
64
|
+
|
65
|
+
* i18n[https://rubygems.org/gems/i18n]
|
66
|
+
* rake[https://rubygems.org/gems/rake]
|
67
|
+
* rubygems[http://docs.rubygems.org/]
|
68
|
+
|
69
|
+
== Download
|
70
|
+
|
71
|
+
==== Source code
|
72
|
+
|
73
|
+
* https://github.com/siefca/i18n-inflector/tree
|
74
|
+
* <tt>git clone git://github.com/siefca/i18n-inflector.git</tt>
|
75
|
+
|
76
|
+
==== Gem
|
77
|
+
|
78
|
+
* https://rubygems.org/gems/i18n-inflector
|
79
|
+
|
80
|
+
== Installation
|
81
|
+
|
82
|
+
* <tt>sudo gem install i18n-inflector</tt>
|
83
|
+
|
84
|
+
== More information
|
85
|
+
|
86
|
+
See i18n-inflector module's documentation for more information.
|
87
|
+
|
88
|
+
== License
|
89
|
+
|
90
|
+
Copyright (c) 2010 by Paweł Wilk.
|
91
|
+
|
92
|
+
\i18n-inflector is copyrighted software owned by Paweł Wilk (pw@gnu.org).
|
93
|
+
You may redistribute and/or modify this software as long as you
|
94
|
+
comply with either the terms of the LGPL (see the file {LGPL-LICENSE}[link:docs/LGPL-LICENSE.html]),
|
95
|
+
or Ruby's license (see the file {COPYING}[link:docs/COPYING.html]).
|
96
|
+
|
97
|
+
THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS
|
98
|
+
OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION,
|
99
|
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
100
|
+
FOR A PARTICULAR PURPOSE.
|
101
|
+
|
data/docs/rdoc.css
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
@import "rdoc_base.css";
|
2
|
+
|
3
|
+
#documentation > ul:first-of-type {
|
4
|
+
padding-bottom: 2em;
|
5
|
+
padding-top: 1.5em;
|
6
|
+
background-position: 20em 0%;
|
7
|
+
background-repeat: no-repeat;
|
8
|
+
}
|
9
|
+
|
10
|
+
#documentation .method-description > p:first-of-type + p {
|
11
|
+
margin-top: 0.5em;
|
12
|
+
}
|
13
|
+
|
14
|
+
#documentation .method-description > ul {
|
15
|
+
margin-left: 1.2em;
|
16
|
+
}
|
17
|
+
|
18
|
+
#documentation .method-description > p + ul {
|
19
|
+
margin-left: 1.8em;
|
20
|
+
}
|