i18n-inflector-rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ j`�[K�m���� �)�#������@d��w�HH�_Ph���F�a��6��&�M�!
2
+ ��s�J�� �/ڂ�\L������������� nV�=�W���r�.�gdd .�7��#����ҫᦲn ��D
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --format nested --color
data/.yardopts ADDED
@@ -0,0 +1,10 @@
1
+ --title 'Simple Inflector for I18n'
2
+ --protected
3
+ --readme README.rdoc
4
+ --no-private
5
+ --hide-void-return
6
+ -
7
+ docs/HISTORY
8
+ ChangeLog
9
+ docs/COPYING
10
+ docs/LGPL-LICENSE
data/ChangeLog ADDED
@@ -0,0 +1,185 @@
1
+ commit 807a61dea750e19bd52fb350d34609e259557bbd
2
+ Author: Paweł Wilk <siefca@gnu.org>
3
+ Date: Fri Jan 14 18:05:40 2011 +0100
4
+
5
+ Version 0.1.0
6
+
7
+ commit 5cd0488a4c5e4bab9f9719162af599984e83d71f
8
+ Author: Paweł Wilk <siefca@gnu.org>
9
+ Date: Fri Jan 14 13:04:43 2011 +0100
10
+
11
+ Adapted to i18n-inflector v.2.0.0
12
+
13
+ commit 20c389bbb9fcae1d216a22b6df39aebd90210767
14
+ Author: Paweł Wilk <siefca@gnu.org>
15
+ Date: Tue Jan 11 14:17:45 2011 +0100
16
+
17
+ Requires stable i18n-inflector
18
+
19
+ commit 01e743e18f55b8734107124303ed191c60937f99
20
+ Author: Paweł Wilk <siefca@gnu.org>
21
+ Date: Tue Jan 11 14:04:05 2011 +0100
22
+
23
+ Version 0.1.0
24
+
25
+ commit c985de4af92f1d1619cfb228ae378d5ca383babd
26
+ Author: Paweł Wilk <siefca@gnu.org>
27
+ Date: Tue Jan 11 13:55:45 2011 +0100
28
+
29
+ Beta
30
+
31
+ commit f338a6a56f36eed25f831d6fbc3fe0127a08931b
32
+ Author: Paweł Wilk <siefca@gnu.org>
33
+ Date: Tue Jan 11 08:28:52 2011 +0100
34
+
35
+ Serious changes that are making it work in a real Rails 3 environment
36
+
37
+ commit 528fcb11daee63711dae36fa6b3b97bd2ab25370
38
+ Author: Paweł Wilk <siefca@gnu.org>
39
+ Date: Tue Jan 11 08:27:43 2011 +0100
40
+
41
+ Added no_inflection_method class method, each added method becomes a helper method
42
+
43
+ commit 17d35aae4c269663b44277751e2d45260abb3c56
44
+ Author: Paweł Wilk <siefca@gnu.org>
45
+ Date: Sun Jan 9 21:03:50 2011 +0100
46
+
47
+ Path fixed
48
+
49
+ commit 289c85c00008b67584e30eb170ce173c35187e84
50
+ Author: Paweł Wilk <siefca@gnu.org>
51
+ Date: Sun Jan 9 21:00:40 2011 +0100
52
+
53
+ Updated Manifest.txt and ChangeLog
54
+
55
+ commit 75b492579a8d25ab3e48a7795a1f351f2f7b379c
56
+ Author: Paweł Wilk <siefca@gnu.org>
57
+ Date: Sun Jan 9 20:58:49 2011 +0100
58
+
59
+ Moved gemspec to root
60
+
61
+ commit c58191d99e80b28d045fd48e14689b0cf4bc49cb
62
+ Author: Paweł Wilk <siefca@gnu.org>
63
+ Date: Sun Jan 9 20:56:04 2011 +0100
64
+
65
+ Added important note to gemspec
66
+
67
+ commit 7fa840a3522b19bb2db9231acdb21faeaedcbfbd
68
+ Author: Paweł Wilk <siefca@gnu.org>
69
+ Date: Sun Jan 9 20:46:16 2011 +0100
70
+
71
+ Specfile fixed: removed non-existent files
72
+
73
+ commit b660e57b969cdb57248a111585278cd20ebbee7a
74
+ Author: Paweł Wilk <siefca@gnu.org>
75
+ Date: Sun Jan 9 20:13:29 2011 +0100
76
+
77
+ Specfile renamed
78
+
79
+ commit 81cffc37a6b30fc7595bb26643588bce1db62da7
80
+ Author: Paweł Wilk <siefca@gnu.org>
81
+ Date: Sun Jan 9 20:12:24 2011 +0100
82
+
83
+ Repository name changed to i18n-inflector-rails
84
+
85
+ commit cda3edcffe9465e021af8380af3ceae0f98ef0a8
86
+ Author: Paweł Wilk <siefca@gnu.org>
87
+ Date: Sun Jan 9 07:11:22 2011 +0100
88
+
89
+ Dependencies fixed
90
+
91
+ commit c1ce77a843490b21233f0c60b35c64d4df731834
92
+ Author: Paweł Wilk <siefca@gnu.org>
93
+ Date: Sun Jan 9 06:45:48 2011 +0100
94
+
95
+ Dependencies back to gemspec
96
+
97
+ commit 745815d7047d7cc39ec48c9265714c110527fc1e
98
+ Author: Paweł Wilk <siefca@gnu.org>
99
+ Date: Sun Jan 9 06:25:45 2011 +0100
100
+
101
+ Call it beta
102
+
103
+ commit a3bf341ae100885b39e770d7cc91ebe7a9734a22
104
+ Author: Paweł Wilk <siefca@gnu.org>
105
+ Date: Sun Jan 9 06:23:37 2011 +0100
106
+
107
+ Dependencies cleaned, gemspec and Rakefile independent from module code (added version.rb for that)
108
+
109
+ commit 5583b7ac968d999ba2a74b3d8457c29df0afba9d
110
+ Author: Paweł Wilk <siefca@gnu.org>
111
+ Date: Sun Jan 9 02:26:43 2011 +0100
112
+
113
+ Gemspec upgraded
114
+
115
+ commit 2c754d88f34bb41b5a377c8f9108687157dca08a
116
+ Author: Paweł Wilk <siefca@gnu.org>
117
+ Date: Sun Jan 9 02:24:14 2011 +0100
118
+
119
+ Added gemspec for compatibility
120
+
121
+ commit 2eebc9668e1b05ac65342ebf8ebb2ded0ac80589
122
+ Author: Paweł Wilk <siefca@gnu.org>
123
+ Date: Sun Jan 9 01:37:12 2011 +0100
124
+
125
+ Deps fixed, Rakefile updated
126
+
127
+ commit 84e8c52a61642a9d5d4f24aa354ea2384bfbf817
128
+ Author: Paweł Wilk <siefca@gnu.org>
129
+ Date: Sun Jan 9 01:18:07 2011 +0100
130
+
131
+ Namespace changed (removed "Backend"), documentation updated
132
+
133
+ commit 037edac820723b7c7452c2f0eae8f572558bb1ad
134
+ Author: Paweł Wilk <siefca@gnu.org>
135
+ Date: Sat Jan 8 16:48:21 2011 +0100
136
+
137
+ Deps updated
138
+
139
+ commit 66c6be2be85b56e88fd27a0cdc0ee34dbbdb846b
140
+ Author: Paweł Wilk <siefca@gnu.org>
141
+ Date: Thu Jan 6 23:15:05 2011 +0100
142
+
143
+ Unit tests stubs removed
144
+
145
+ commit 41e9409414c75f5b5ef77e69ce62a291d321d04f
146
+ Author: Paweł Wilk <siefca@gnu.org>
147
+ Date: Thu Jan 6 23:13:45 2011 +0100
148
+
149
+ Added Railtie, added common files for older Rails versions just in case
150
+
151
+ commit 818027d17d91171499b410e2e7628422e61eb165
152
+ Author: Paweł Wilk <siefca@gnu.org>
153
+ Date: Thu Jan 6 23:12:42 2011 +0100
154
+
155
+ Added rspec examples
156
+
157
+ commit f564dc4c25060961b2838ddae03056fbb9f5fa2a
158
+ Author: Paweł Wilk <siefca@gnu.org>
159
+ Date: Thu Jan 6 23:11:49 2011 +0100
160
+
161
+ Method names changed, inflection options extraction fixed, documentation updated.
162
+
163
+ commit e0f0fd9086b00efec6e1e979c0a8ea2d03904371
164
+ Author: Paweł Wilk <siefca@gnu.org>
165
+ Date: Thu Jan 6 23:09:46 2011 +0100
166
+
167
+ Fixed error reporting class: message is more generic
168
+
169
+ commit fc1c7ea3aa2d4011075d05926fcc8baa5758f322
170
+ Author: Paweł Wilk <siefca@gnu.org>
171
+ Date: Thu Jan 6 23:09:09 2011 +0100
172
+
173
+ Dependences changed: railties and rspec-rails added
174
+
175
+ commit cf63e0e3b0cf0388c11143bbe67868b8fbd5bdd9
176
+ Author: Paweł Wilk <siefca@gnu.org>
177
+ Date: Sun Jan 2 16:03:20 2011 +0100
178
+
179
+ Added ChangeLog and Manifest.txt
180
+
181
+ commit 4dfee2aa8b56922e4bfc8bd8d2a64456cde256c6
182
+ Author: Paweł Wilk <siefca@gnu.org>
183
+ Date: Sun Jan 2 16:01:46 2011 +0100
184
+
185
+ Initial revision
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ # -*- ruby -*-
2
+
3
+ source :gemcutter
4
+
5
+ gem "i18n-inflector", "~>2.0.0"
6
+ gem "railties", "~>3.0.0"
7
+ gem "actionpack", "~>3.0.0"
8
+
9
+ gem "hoe-yard", ">=0.1.2", :group => [:development, :test]
10
+ gem "rspec", ">=2.3.0", :group => [:development, :test]
11
+ gem "yard", ">=0.6.4", :group => [:development, :test]
12
+ gem "bundler", ">=1.0.7", :group => [:development, :test]
13
+ gem "hoe-bundler", ">=1.0.0", :group => [:development, :test]
14
+ gem "hoe-yard", ">=0.1.2", :group => [:development, :test]
15
+ gem "hoe", ">=2.8.0", :group => [:development, :test]
16
+
17
+ # vim: syntax=ruby
data/LGPL-LICENSE ADDED
@@ -0,0 +1,169 @@
1
+ <tt>
2
+
3
+ GNU LESSER GENERAL PUBLIC LICENSE
4
+ Version 3, 29 June 2007
5
+
6
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
7
+ Everyone is permitted to copy and distribute verbatim copies
8
+ of this license document, but changing it is not allowed.
9
+
10
+
11
+ This version of the GNU Lesser General Public License incorporates
12
+ the terms and conditions of version 3 of the GNU General Public
13
+ License, supplemented by the additional permissions listed below.
14
+
15
+ 0. Additional Definitions.
16
+
17
+ As used herein, "this License" refers to version 3 of the GNU Lesser
18
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
19
+ General Public License.
20
+
21
+ "The Library" refers to a covered work governed by this License,
22
+ other than an Application or a Combined Work as defined below.
23
+
24
+ An "Application" is any work that makes use of an interface provided
25
+ by the Library, but which is not otherwise based on the Library.
26
+ Defining a subclass of a class defined by the Library is deemed a mode
27
+ of using an interface provided by the Library.
28
+
29
+ A "Combined Work" is a work produced by combining or linking an
30
+ Application with the Library. The particular version of the Library
31
+ with which the Combined Work was made is also called the "Linked
32
+ Version".
33
+
34
+ The "Minimal Corresponding Source" for a Combined Work means the
35
+ Corresponding Source for the Combined Work, excluding any source code
36
+ for portions of the Combined Work that, considered in isolation, are
37
+ based on the Application, and not on the Linked Version.
38
+
39
+ The "Corresponding Application Code" for a Combined Work means the
40
+ object code and/or source code for the Application, including any data
41
+ and utility programs needed for reproducing the Combined Work from the
42
+ Application, but excluding the System Libraries of the Combined Work.
43
+
44
+ 1. Exception to Section 3 of the GNU GPL.
45
+
46
+ You may convey a covered work under sections 3 and 4 of this License
47
+ without being bound by section 3 of the GNU GPL.
48
+
49
+ 2. Conveying Modified Versions.
50
+
51
+ If you modify a copy of the Library, and, in your modifications, a
52
+ facility refers to a function or data to be supplied by an Application
53
+ that uses the facility (other than as an argument passed when the
54
+ facility is invoked), then you may convey a copy of the modified
55
+ version:
56
+
57
+ a) under this License, provided that you make a good faith effort to
58
+ ensure that, in the event an Application does not supply the
59
+ function or data, the facility still operates, and performs
60
+ whatever part of its purpose remains meaningful, or
61
+
62
+ b) under the GNU GPL, with none of the additional permissions of
63
+ this License applicable to that copy.
64
+
65
+ 3. Object Code Incorporating Material from Library Header Files.
66
+
67
+ The object code form of an Application may incorporate material from
68
+ a header file that is part of the Library. You may convey such object
69
+ code under terms of your choice, provided that, if the incorporated
70
+ material is not limited to numerical parameters, data structure
71
+ layouts and accessors, or small macros, inline functions and templates
72
+ (ten or fewer lines in length), you do both of the following:
73
+
74
+ a) Give prominent notice with each copy of the object code that the
75
+ Library is used in it and that the Library and its use are
76
+ covered by this License.
77
+
78
+ b) Accompany the object code with a copy of the GNU GPL and this license
79
+ document.
80
+
81
+ 4. Combined Works.
82
+
83
+ You may convey a Combined Work under terms of your choice that,
84
+ taken together, effectively do not restrict modification of the
85
+ portions of the Library contained in the Combined Work and reverse
86
+ engineering for debugging such modifications, if you also do each of
87
+ the following:
88
+
89
+ a) Give prominent notice with each copy of the Combined Work that
90
+ the Library is used in it and that the Library and its use are
91
+ covered by this License.
92
+
93
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
94
+ document.
95
+
96
+ c) For a Combined Work that displays copyright notices during
97
+ execution, include the copyright notice for the Library among
98
+ these notices, as well as a reference directing the user to the
99
+ copies of the GNU GPL and this license document.
100
+
101
+ d) Do one of the following:
102
+
103
+ 0) Convey the Minimal Corresponding Source under the terms of this
104
+ License, and the Corresponding Application Code in a form
105
+ suitable for, and under terms that permit, the user to
106
+ recombine or relink the Application with a modified version of
107
+ the Linked Version to produce a modified Combined Work, in the
108
+ manner specified by section 6 of the GNU GPL for conveying
109
+ Corresponding Source.
110
+
111
+ 1) Use a suitable shared library mechanism for linking with the
112
+ Library. A suitable mechanism is one that (a) uses at run time
113
+ a copy of the Library already present on the user's computer
114
+ system, and (b) will operate properly with a modified version
115
+ of the Library that is interface-compatible with the Linked
116
+ Version.
117
+
118
+ e) Provide Installation Information, but only if you would otherwise
119
+ be required to provide such information under section 6 of the
120
+ GNU GPL, and only to the extent that such information is
121
+ necessary to install and execute a modified version of the
122
+ Combined Work produced by recombining or relinking the
123
+ Application with a modified version of the Linked Version. (If
124
+ you use option 4d0, the Installation Information must accompany
125
+ the Minimal Corresponding Source and Corresponding Application
126
+ Code. If you use option 4d1, you must provide the Installation
127
+ Information in the manner specified by section 6 of the GNU GPL
128
+ for conveying Corresponding Source.)
129
+
130
+ 5. Combined Libraries.
131
+
132
+ You may place library facilities that are a work based on the
133
+ Library side by side in a single library together with other library
134
+ facilities that are not Applications and are not covered by this
135
+ License, and convey such a combined library under terms of your
136
+ choice, if you do both of the following:
137
+
138
+ a) Accompany the combined library with a copy of the same work based
139
+ on the Library, uncombined with any other library facilities,
140
+ conveyed under the terms of this License.
141
+
142
+ b) Give prominent notice with the combined library that part of it
143
+ is a work based on the Library, and explaining where to find the
144
+ accompanying uncombined form of the same work.
145
+
146
+ 6. Revised Versions of the GNU Lesser General Public License.
147
+
148
+ The Free Software Foundation may publish revised and/or new versions
149
+ of the GNU Lesser General Public License from time to time. Such new
150
+ versions will be similar in spirit to the present version, but may
151
+ differ in detail to address new problems or concerns.
152
+
153
+ Each version is given a distinguishing version number. If the
154
+ Library as you received it specifies that a certain numbered version
155
+ of the GNU Lesser General Public License "or any later version"
156
+ applies to it, you have the option of following the terms and
157
+ conditions either of that published version or of any later version
158
+ published by the Free Software Foundation. If the Library as you
159
+ received it does not specify a version number of the GNU Lesser
160
+ General Public License, you may choose any version of the GNU Lesser
161
+ General Public License ever published by the Free Software Foundation.
162
+
163
+ If the Library as you received it specifies that a proxy can decide
164
+ whether future versions of the GNU Lesser General Public License shall
165
+ apply, that proxy's public statement of acceptance of any version is
166
+ permanent authorization for you to choose that version for the
167
+ Library.
168
+
169
+ </tt>
data/Manifest.txt ADDED
@@ -0,0 +1,23 @@
1
+ .rspec
2
+ .yardopts
3
+ ChangeLog
4
+ Gemfile
5
+ LGPL-LICENSE
6
+ Manifest.txt
7
+ README.rdoc
8
+ Rakefile
9
+ docs/COPYING
10
+ docs/HISTORY
11
+ docs/LEGAL
12
+ docs/LGPL-LICENSE
13
+ docs/TODO
14
+ docs/rdoc.css
15
+ i18n-inflector-rails.gemspec
16
+ init.rb
17
+ lib/i18n-inflector-rails.rb
18
+ lib/i18n-inflector-rails/errors.rb
19
+ lib/i18n-inflector-rails/inflector.rb
20
+ lib/i18n-inflector-rails/railtie.rb
21
+ lib/i18n-inflector-rails/version.rb
22
+ spec/inflector_spec.rb
23
+ spec/spec_helper.rb
data/README.rdoc ADDED
@@ -0,0 +1,154 @@
1
+ = Simple I18n Inflector for Rails
2
+
3
+ <b>i18n-inflector-rails version <tt>1.0</tt></b> (<b><tt>Sexparty</tt></b>)
4
+
5
+
6
+
7
+ * https://rubygems.org/gems/i18n-inflector-rails
8
+ * https://github.com/siefca/i18n-inflector-rails/tree
9
+ * mailto:pw@gnu.org
10
+
11
+ == Summary
12
+
13
+ This Rails plug-in contains bindings for the I18n Inflector module for Ruby's I18n.
14
+ It overwrites the translate() method from Rails in a way that it will
15
+ interpolate additional inflection tokens present in translations.
16
+ These tokens may appear in *patterns* which are contained within
17
+ <tt>@{</tt> and <tt>}</tt> symbols.
18
+
19
+ == Why?
20
+
21
+ It's intended to be used in a projects where tranlations are performed
22
+ by many people, yet there is a need to substitute fragments of text
23
+ depending on user's gender, person or other data.
24
+
25
+ To achieve similar functionality lambdas can be used but including
26
+ proc objects in translations may be considered as the unsafe idea.
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 should use this module.
31
+
32
+ == Synopsis
33
+
34
+ translate('.welcome')
35
+
36
+ ===== In a YAML file:
37
+
38
+ en:
39
+ welcome: "Dear @{f:Lady|m:Sir|n:You|All}"
40
+
41
+ en:
42
+ i18n:
43
+ inflections:
44
+ gender:
45
+ f: "female"
46
+ m: "male"
47
+ n: "neuter"
48
+ @female: @f
49
+ @male: @m
50
+ @neuter: @n
51
+ man: @male
52
+ woman: @female
53
+ default: neuter
54
+
55
+ ===== In a controller:
56
+
57
+ class ApplicationController < ActionController::Base
58
+
59
+ inflection_method :gender
60
+
61
+ # assuming that @gender is set somewhere
62
+ def gender
63
+ @gender || nil
64
+ end
65
+
66
+ end
67
+
68
+ class UsersController < ApplicationController
69
+
70
+ # t() will call method gender() from the current context
71
+ # to get the inflection token
72
+ def say_welcome
73
+ t('welcome')
74
+ # => "Dear Sir"
75
+ end
76
+
77
+ end
78
+
79
+ == Description
80
+
81
+ You can choose different kinds (gender, title, person, time, author, etc.)
82
+ of tokens to group them in a meaningful, semantical sets. That means you can
83
+ apply I18n Inflector to do simple inflection by a gender or a person, when some
84
+ language requires it.
85
+
86
+ This module adds +inflection_method+ clause that can be used
87
+ in controllers and views. Using that clause makes it easy to register
88
+ methods that will be called to obtain mentioned inflection options.
89
+
90
+ This module uses i18n-inflector[https://rubygems.org/gems/i18n-inflector]
91
+ module which allows passing inflection options to the translate method.
92
+ You may find i18n-inflector default objects very helpful since they
93
+ allow you to read inflection data in many different ways. You may, for
94
+ example, use it to generate forms containing languages that are using inflection,
95
+ all known inflection kinds or tokens assigned to them. To access default inflector
96
+ bound to default I18n backend use:
97
+ I18n.inflector
98
+
99
+ See {whole documentation}[http://rubydoc.info/gems/i18n-inflector-rails/] for more info about the usage.
100
+ To understand how the I18n Inflector works please read {I18n Inflector documentation}[http://rubydoc.info/gems/i18n-inflector/file/README.rdoc].
101
+
102
+ == Requirements
103
+
104
+ * i18n-inflector[https://rubygems.org/gems/i18n-inflector]
105
+ * actionpack[https://rubygems.org/gems/actionpack]
106
+ * rake[https://rubygems.org/gems/rake]
107
+ * rubygems[http://docs.rubygems.org/]
108
+
109
+ == Download
110
+
111
+ ==== Source code
112
+
113
+ * https://github.com/siefca/i18n-inflector-rails/tree
114
+ * <tt>git clone git://github.com/siefca/i18n-inflector-rails.git</tt>
115
+
116
+ ==== Gem
117
+
118
+ * https://rubygems.org/gems/i18n-inflector-rails
119
+
120
+ == Installation
121
+
122
+ * <tt>sudo gem install i18n-inflector-rails</tt>
123
+
124
+ == Specs
125
+
126
+ You can run RSpec examples both with
127
+
128
+ * <tt>rake spec</tt> or just <tt>rake</tt>
129
+ * run a test file directly, e.g. <tt>ruby -Ilib -Ispec spec/inflector_spec.rb</tt>
130
+
131
+ == More information
132
+
133
+ See {whole documentation}[http://rubydoc.info/gems/i18n-inflector-rails/] for more info about the usage.
134
+
135
+ See {I18n::Inflector::Rails} module documentation for detailed information.
136
+
137
+ == Credits
138
+
139
+ {Heise Media Polska}[http://www.heise-online.pl/] supports Free Software and has
140
+ contributed to this plug-in by paying for me to eat when I've been coding.
141
+
142
+ == License
143
+
144
+ Copyright (c) 2011 by Paweł Wilk.
145
+
146
+ i18n-inflector-rails is copyrighted software owned by Paweł Wilk (pw@gnu.org).
147
+ You may redistribute and/or modify this software as long as you
148
+ comply with either the terms of the LGPL (see {file:LGPL-LICENSE}),
149
+ or Ruby's license (see {file:COPYING}).
150
+
151
+ THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS
152
+ OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION,
153
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
154
+ FOR A PARTICULAR PURPOSE.