i18n-inflector-3 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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/README.md ADDED
@@ -0,0 +1,259 @@
1
+ # i18n-inflector
2
+
3
+ **i18n-inflector-3 version `3.0.0`** (Ruby 3.4+ compatible fork)
4
+
5
+ * https://github.com/slbug/i18n-inflector
6
+ * mailto:sl.bug.sl@gmail.com
7
+
8
+ ## Summary
9
+
10
+ This library contains a backend module for I18n that adds extra functionality to the standard backend. It overwrites the translate method to interpolate additional inflection tokens present in translations.
11
+
12
+ This is a modernized fork of the original i18n-inflector gem, updated to work with Ruby 3.4+ and Ruby 4.0.0-preview2.
13
+
14
+ ## Synopsis
15
+
16
+ ```ruby
17
+ require 'i18n-inflector'
18
+
19
+ I18n.translate('to_be', number: :singular,
20
+ tense: :past,
21
+ person: 2)
22
+ #=> You were here
23
+
24
+ I18n.translate('welcome', gender: :female)
25
+ #=> Dear Lady
26
+ ```
27
+
28
+ ## Why?
29
+
30
+ You can use I18n Inflector to create translations for highly inflected languages (like those belonging to Slavic language family). You can also use it in translation services that may operate on sentences instead of exact words.
31
+
32
+ ## When?
33
+
34
+ It is intended to be used in web projects or other projects where translations are performed by many people, yet there is a need to inflect sentences with external variables. To achieve similar functionality lambdas can be used, but including many Proc objects might be considered unsafe or memory consuming.
35
+
36
+ See [i18n-inflector-rails](https://rubygems.org/gems/i18n-inflector-rails) if you need Rails integration.
37
+
38
+ ## How?
39
+
40
+ I18n Inflector lets you build your own inflection patterns contained in translation entries. The patterns may contain simple conditions and tokens, which combined with parameters passed to `I18n.translate` method can produce inflected strings.
41
+
42
+ * See [USAGE](docs/USAGE) for detailed information about the usage.
43
+ * See [EXAMPLES](docs/EXAMPLES) for examples.
44
+ * See [whole documentation](http://rubydoc.info/gems/i18n-inflector-3/) to browse all documents.
45
+
46
+ ## Features
47
+
48
+ * Inline inflection using patterns in translation data
49
+ * Key-based inflection using individual inflection keys
50
+ * Definable inflection kinds and tokens
51
+ * Easy to use public API for inflection data
52
+ * Configurable using special scope of translation data
53
+ * Lazily evaluated Proc and Method objects as inflection options
54
+ * Complex patterns support; inflection by more than one kind at a time
55
+ * Negative matching, aliases, default tokens, token groups and more…
56
+
57
+ ## Description
58
+
59
+ The I18n Inflector extends the translate method from I18n to interpolate additional inflection tokens present in translations. These tokens may appear in **patterns** which are contained within `@{` and `}` symbols. Configuration is stored in translation data, in a scope `<locale>.i18n.inflections`, where `locale` is a locale subtree.
60
+
61
+ You can create your own inflection kinds (gender, title, person, time, author, etc.) to group tokens in meaningful, semantical sets. That means you can apply Inflector to do simple inflection by gender or person when a language requires it.
62
+
63
+ It adds the `inflector` object to the default backend so you can use many methods for accessing loaded inflection data at runtime, or to set up global switches that control the engine.
64
+
65
+ ## Short example
66
+
67
+ Example configuration using translation data:
68
+
69
+ ```yaml
70
+ en:
71
+ i18n:
72
+ inflections:
73
+ gender:
74
+ f: "female"
75
+ m: "male"
76
+ n: "neuter"
77
+ female: :@f
78
+ male: :@m
79
+ default: :n
80
+ ```
81
+
82
+ Example translation data:
83
+
84
+ ```yaml
85
+ en:
86
+ welcome: "Dear @{f:Lady|m:Sir|n:You|All}!"
87
+
88
+ '@same_but_as_key':
89
+ f: "Lady"
90
+ m: "Sir"
91
+ n: "You"
92
+ '@prefix': "Dear "
93
+ '@suffix': "!"
94
+ '@free': "All"
95
+ ```
96
+
97
+ ### Note about YAML parsing
98
+
99
+ The examples use symbol notation (`:@f`) for special values to ensure compatibility with modern YAML parsers including Psych.
100
+
101
+ ## New features
102
+
103
+ From version 2.1.0 the Inflector supports **named patterns**, which can be used when there is a need to be strict and/or to use the same token names but assigned to different kinds. Example:
104
+
105
+ ```yaml
106
+ welcome: "Dear @gender{f:Lady|m:Sir|n:You|All}"
107
+ ```
108
+
109
+ From version 2.2.0 the Inflector supports **complex patterns**, which can be used to inflect a sentence or word by more than one kind. This is very helpful for highly inflected languages. Example:
110
+
111
+ ```yaml
112
+ welcome: "Dear @gender+number{f+s:Lady|f+p:Ladies|m+s:Sir|m+p:Gentlemen|All}"
113
+ ```
114
+
115
+ ## Modernization (v3.0.0)
116
+
117
+ This fork has been modernized for Ruby 3.4+ and Ruby 4.0.0-preview2:
118
+
119
+ ### Breaking Changes
120
+
121
+ * **Minimum Ruby version**: 3.4+ (was 1.9+)
122
+ * **Gem name**: Changed to `i18n-inflector-3` to avoid conflicts
123
+ * **Build system**: Migrated from Hoe to standard Bundler/Gemspec
124
+ * **Test framework**: Migrated from Test::Unit to Minitest
125
+
126
+ ### Technical Improvements
127
+
128
+ * **Frozen string literals**: All files use `frozen_string_literal: true`
129
+ * **HSet implementation**: Updated to use public `Set#include?` API instead of internal `@hash`
130
+ * **Dependencies**: Updated to modern versions
131
+ * **Code style**: Modernized Ruby idioms and syntax
132
+
133
+ ### Migration from v2.6.7
134
+
135
+ No API changes - this is a drop-in replacement. Just update your Gemfile:
136
+
137
+ ```ruby
138
+ # Old
139
+ gem 'i18n-inflector', '~> 2.6'
140
+
141
+ # New
142
+ gem 'i18n-inflector-3', '~> 3.0'
143
+ ```
144
+
145
+ The require statement remains the same:
146
+
147
+ ```ruby
148
+ require 'i18n-inflector' # Still works!
149
+ ```
150
+
151
+ ## Requirements
152
+
153
+ * [i18n](https://rubygems.org/gems/i18n) >= 0.6.0
154
+ * [rake](https://rubygems.org/gems/rake) >= 13.0
155
+ * Ruby >= 3.4
156
+
157
+ ## Download
158
+
159
+ ### Source code
160
+
161
+ * https://github.com/slbug/i18n-inflector
162
+ * `git clone git://github.com/slbug/i18n-inflector.git`
163
+
164
+ ### Gem
165
+
166
+ * https://rubygems.org/gems/i18n-inflector-3
167
+
168
+ ## Installation
169
+
170
+ ```bash
171
+ gem install i18n-inflector-3
172
+ ```
173
+
174
+ Or add to your Gemfile:
175
+
176
+ ```ruby
177
+ gem 'i18n-inflector-3', '~> 3.0', require: 'i18n-inflector'
178
+ ```
179
+
180
+ ## Detailed example
181
+
182
+ **YAML:**
183
+
184
+ ```yaml
185
+ en:
186
+ i18n:
187
+ inflections:
188
+ gender:
189
+ f: "female"
190
+ m: "male"
191
+ n: "neuter"
192
+ o: "other"
193
+ default: :n
194
+
195
+ welcome: "Dear @{f:Lady|m:Sir|n:You|All}"
196
+ ```
197
+
198
+ **Code:**
199
+
200
+ ```ruby
201
+ I18n.t('welcome')
202
+ # => "Dear You"
203
+
204
+ I18n.t('welcome', gender: :m)
205
+ # => "Dear Sir"
206
+
207
+ I18n.t('welcome', gender: :unknown)
208
+ # => "Dear You"
209
+
210
+ I18n.inflector.options.unknown_defaults = false
211
+ I18n.t('welcome', gender: :unknown)
212
+ # => "Dear All"
213
+
214
+ I18n.t('welcome', gender: :o)
215
+ # => "Dear All"
216
+
217
+ I18n.inflector.options.excluded_defaults = true
218
+ I18n.t('welcome', gender: :o)
219
+ # => "Dear You"
220
+ ```
221
+
222
+ ## More information
223
+
224
+ * See `I18n::Inflector::API` class documentation for detailed information about the API
225
+ * See `I18n::Backend::Inflector` module documentation for detailed information about the internals
226
+
227
+ ## Tests
228
+
229
+ You can run tests with:
230
+
231
+ ```bash
232
+ bundle exec rake test
233
+ # or
234
+ ./bin/test
235
+ ```
236
+
237
+ ## Common rake tasks
238
+
239
+ * `bundle exec rake test` – performs tests
240
+ * `bundle exec rake gem` – builds package (output in the subdirectory `pkg`)
241
+ * `bundle exec rake docs` – render the documentation (output in the subdirectory `doc`)
242
+
243
+ ## Credits
244
+
245
+ Original gem by Paweł Wilk (pw@gnu.org).
246
+
247
+ [Heise Media Polska](http://www.heise-online.pl/) supports Free Software and contributed to the original library.
248
+
249
+ Modernization for Ruby 3.4+ by Alexander Grebennik.
250
+
251
+ ## License
252
+
253
+ Copyright (c) 2011-2013 by Paweł Wilk.
254
+ Copyright (c) 2025 by Alexander Grebennik (modernization).
255
+
256
+ i18n-inflector is copyrighted software owned by Paweł Wilk (pw@gnu.org).
257
+ You may redistribute and/or modify this software as long as you comply with either the terms of the LGPL (see [LGPL](docs/LGPL)), or Ruby's license (see [COPYING](docs/COPYING)).
258
+
259
+ THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
data/docs/COPYING ADDED
@@ -0,0 +1,57 @@
1
+ i18n-inflector is copyrighted free software owned by Paweł Wilk (pw@gnu.org). The Owner of this software permits you to redistribute and/or modify the software under either the terms of the LGPL version 3 (see the file {file:docs/LGPL LGPL-LICENSE}), or the conditions below ("Ruby License").
2
+
3
+ == 1.
4
+
5
+ You may make and give away verbatim copies of the source form of this software without restriction, provided that you retain ALL of the
6
+ original copyright notices and associated disclaimers.
7
+
8
+ == 2.
9
+
10
+ You may modify your copy of the software in any way, provided that you do at least ONE of the following:
11
+
12
+ a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said
13
+ modifications to Usenet or an equivalent medium, or by allowing
14
+ the author to include your modifications in the software.
15
+
16
+ b) use the modified software only within your corporation or
17
+ organization.
18
+
19
+ c) give non-standard binaries non-standard names, with
20
+ instructions on where to get the original software distribution.
21
+
22
+ d) make other distribution arrangements with the Owner.
23
+
24
+ == 3.
25
+
26
+ You may distribute the software in object code or binary form, provided that you do at least ONE of the following:
27
+
28
+ a) distribute the binaries and library files of the software,
29
+ together with instructions (in a manual page or equivalent)
30
+ on where to get the original distribution.
31
+
32
+ b) accompany the distribution with the machine-readable source of
33
+ the software.
34
+
35
+ c) give non-standard binaries non-standard names, with
36
+ instructions on where to get the original software distribution.
37
+
38
+ d) make other distribution arrangements with the Owner.
39
+
40
+ == 4.
41
+
42
+ You may modify and include parts of the software into any other software (possibly commercial), provided you comply with the terms in
43
+ Sections 1, 2, and 3 above. But some files in the distribution are not written by the Owner, so they may be made available to you
44
+ under different terms.
45
+
46
+ For the list of those files and their copying conditions, see the
47
+ file LEGAL.
48
+
49
+ == 5.
50
+
51
+ The scripts and library files supplied as input to or produced as output from the software do not automatically fall under the
52
+ copyright of the software, but belong to whoever generated them, and may be sold commercially, and may be aggregated with this software.
53
+
54
+ == 6.
55
+
56
+ THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
57
+