i18n-inflector 1.0.11 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.yardopts CHANGED
@@ -4,8 +4,9 @@
4
4
  --no-private
5
5
  --hide-void-return
6
6
  -
7
+ docs/RELATIONS
7
8
  docs/HISTORY
8
9
  ChangeLog
9
10
  docs/COPYING
10
- docs/LGPL-LICENSE
11
+ docs/LGPL
11
12
  docs/TODO
data/ChangeLog CHANGED
@@ -1,14 +1,149 @@
1
- commit d8aedac664b622abd120e6b00f4de63b060fa887
1
+ commit e7a6eb41eab2f76881169eeabb03e9540adeeb0e
2
2
  Author: Paweł Wilk <siefca@gnu.org>
3
- Date: Sat Jan 15 15:01:05 2011 +0100
3
+ Date: Fri Jan 14 17:33:44 2011 +0100
4
4
 
5
- Compatibility release 1.0.11
5
+ Version 2.0.0 ready to be released
6
6
 
7
- commit e5390e53a44e610883d818d8230515157df5e6a8
7
+ commit 9d87da0b8781be172ed7216aafc57e3bde096504
8
8
  Author: Paweł Wilk <siefca@gnu.org>
9
- Date: Sat Jan 15 14:58:30 2011 +0100
9
+ Date: Fri Jan 14 17:29:19 2011 +0100
10
10
 
11
- Fixed doco and Rakefile
11
+ Added more tests and cleaned up conditional expressions in InflectionData
12
+
13
+ commit 295f2e3c98a23b1109e8e8355c008e9d59ecd010
14
+ Author: Paweł Wilk <siefca@gnu.org>
15
+ Date: Fri Jan 14 16:26:20 2011 +0100
16
+
17
+ Version 2.0.0 tested in Rails 3 environment
18
+
19
+ commit 62785a25f593460d91294cd87fdde254acb5f2e3
20
+ Author: Paweł Wilk <siefca@gnu.org>
21
+ Date: Fri Jan 14 15:06:14 2011 +0100
22
+
23
+ Speed improvements.
24
+
25
+ commit 1b3ac06a779288f8f9584dd0fc4f50e9f1728a34
26
+ Author: Paweł Wilk <siefca@gnu.org>
27
+ Date: Fri Jan 14 12:54:40 2011 +0100
28
+
29
+ Updated version information in README
30
+
31
+ commit d76bd2a91323c8f612a7328191b69014353a3802
32
+ Author: Paweł Wilk <siefca@gnu.org>
33
+ Date: Fri Jan 14 12:52:13 2011 +0100
34
+
35
+ Version 2.0.0
36
+
37
+ commit 33c2e77ecef865c7f1813c1a7db899e66be98c13
38
+ Author: Paweł Wilk <siefca@gnu.org>
39
+ Date: Fri Jan 14 12:36:36 2011 +0100
40
+
41
+ Version 1.2.0
42
+
43
+ commit c86af221fe2a3d7f0bcba863a2ef9e2a91d4825a
44
+ Author: Paweł Wilk <siefca@gnu.org>
45
+ Date: Fri Jan 14 12:31:47 2011 +0100
46
+
47
+ Documentation updates, code cleanups
48
+
49
+ commit 2fb80a5725325071b9dbad85c8662e263edcfbcc
50
+ Author: Paweł Wilk <siefca@gnu.org>
51
+ Date: Fri Jan 14 02:55:12 2011 +0100
52
+
53
+ README.rdoc fixed
54
+
55
+ commit f39db3b5a29ee34706326d337cc766983a1bfb9b
56
+ Author: Paweł Wilk <siefca@gnu.org>
57
+ Date: Fri Jan 14 02:51:52 2011 +0100
58
+
59
+ Added RELATIONS to documentation
60
+
61
+ commit bf8a9799aa0600eddecbf95a981947cf2ef805ef
62
+ Author: Paweł Wilk <siefca@gnu.org>
63
+ Date: Fri Jan 14 02:51:06 2011 +0100
64
+
65
+ Documentation updated
66
+
67
+ commit 4bf626399b4556ee2a4aaa76a9a7559bd20464a3
68
+ Author: Paweł Wilk <siefca@gnu.org>
69
+ Date: Thu Jan 13 18:47:08 2011 +0100
70
+
71
+ Serious refactoring
72
+
73
+ - Interpolating method moved to I18n::Inflector
74
+ - Loading inflections now creates InflactionData object that feeds I18n::Inflector::Core
75
+ - Locale management created in I18n::Inflector::Core (pluggable databases)
76
+ - Added safe_data() and data() methods to Core in order to simplify inflection database calls
77
+ - Removed send() calls, removed bridge; not needed anymore
78
+ - InflectionData initializer can now be feeded with locale (it's also stored there)
79
+ - Removed unneeded I18n::Inflector::Util incusion in I18n::Inflector::Backend
80
+
81
+ commit 0fc113797bdd9ff7bd3d1e953385c6670064b936
82
+ Author: Paweł Wilk <siefca@gnu.org>
83
+ Date: Thu Jan 13 06:36:19 2011 +0100
84
+
85
+ I18n::Inflector is a regular module and inflector is sticked to the backend again
86
+
87
+ New class I18n::Inflector::Core is API to deal with inflection data.
88
+ Inflector is now @inflector in altered I18n::Backend::Simple and I18n.inflector is a proxy method
89
+
90
+ commit cf547a804c4c90418e8cfb69de405660a959eba9
91
+ Author: Paweł Wilk <siefca@gnu.org>
92
+ Date: Thu Jan 13 05:25:21 2011 +0100
93
+
94
+ Options are now kind of InflectionOptions and are controlled by I18n::Inflector class methods
95
+
96
+ commit a7cbc568ca90d67a4c7ef2b9c9c08f1c5dbc94f0
97
+ Author: Paweł Wilk <siefca@gnu.org>
98
+ Date: Thu Jan 13 01:56:15 2011 +0100
99
+
100
+ Errors moved out if I18n::Inflector::InflectionData, documentation updated a bit
101
+
102
+ commit 324a647292c9e9d5121b0b2bd18fb83151458afb
103
+ Author: Paweł Wilk <siefca@gnu.org>
104
+ Date: Wed Jan 12 22:13:52 2011 +0100
105
+
106
+ Code refactored. Added class InflectionData and keeping all data in its instance
107
+
108
+ Aliases are now keeped along with tokens in one hash, there are also some new API methods
109
+
110
+ commit faa4ca16bbafb572e7d209e139b8664406040a43
111
+ Author: Paweł Wilk <siefca@gnu.org>
112
+ Date: Wed Jan 12 01:36:26 2011 +0100
113
+
114
+ Serious refactoring and namespace changes
115
+
116
+ - Most of inflector-specific API methods are now in I18n::Inflector
117
+ - Core logic (loading and translations) in I18n::Backend::Inflector
118
+ - Useful methods used in both modules listed above in I18n::Inflector::Util
119
+ - Added new method for checking if token exists
120
+ - Added bridge between I18n::Inflector and I18n::Backend::Inflector (init_frontend)
121
+ - Started working on feature for is_* methods (additional argument narrows tests to some kind)
122
+ - Changed method names to more intuitive
123
+
124
+ commit edc402233f62b6a135882a28fc1c284d5a5fee99
125
+ Author: Paweł Wilk <siefca@gnu.org>
126
+ Date: Tue Jan 11 21:50:28 2011 +0100
127
+
128
+ Added support for negative matches in patterns
129
+
130
+ commit 6cf50a1b31c61a0f0ddb102d8b5f1a68bf769247
131
+ Author: Paweł Wilk <siefca@gnu.org>
132
+ Date: Tue Jan 11 16:04:16 2011 +0100
133
+
134
+ Added support for token groups seaprated by commas
135
+
136
+ commit e399d04ba157e16fe45c55b41ff5cb313ce6da3e
137
+ Author: Paweł Wilk <siefca@gnu.org>
138
+ Date: Tue Jan 11 08:21:32 2011 +0100
139
+
140
+ Inflected locale testing is not raising errors when entered locale is invalid
141
+
142
+ commit a336e2376c3e0e2e50f1404529dd5e726732583b
143
+ Author: Paweł Wilk <siefca@gnu.org>
144
+ Date: Mon Jan 10 05:38:14 2011 +0100
145
+
146
+ Fix for apps initializing translations via YAML files
12
147
 
13
148
  commit dc81afa48b36336b9efde0ce9019637edc0474f8
14
149
  Author: Paweł Wilk <siefca@gnu.org>
data/Gemfile CHANGED
@@ -9,6 +9,7 @@ gem "test_declarative", ">=0.0.4", :group => [:development, :test]
9
9
  gem "yard", ">=0.6.4", :group => [:development, :test]
10
10
  gem "bundler", ">=1.0.7", :group => [:development, :test]
11
11
  gem "hoe-bundler", ">=1.0.0", :group => [:development, :test]
12
+ gem "hoe-yard", ">=0.1.2", :group => [:development, :test]
12
13
  gem "hoe", ">=2.8.0", :group => [:development, :test]
13
14
 
14
15
  # vim: syntax=ruby
data/Manifest.txt CHANGED
@@ -9,14 +9,18 @@ ci/i18n-inflector.gemspec
9
9
  docs/COPYING
10
10
  docs/HISTORY
11
11
  docs/LEGAL
12
- docs/LGPL-LICENSE
12
+ docs/LGPL
13
+ docs/RELATIONS
13
14
  docs/TODO
14
15
  docs/rdoc.css
15
16
  lib/i18n-inflector.rb
17
+ lib/i18n-inflector/backend.rb
16
18
  lib/i18n-inflector/errors.rb
19
+ lib/i18n-inflector/inflection_data.rb
17
20
  lib/i18n-inflector/inflector.rb
18
21
  lib/i18n-inflector/long_comments.rb
19
- lib/i18n-inflector/shortcuts.rb
22
+ lib/i18n-inflector/options.rb
23
+ lib/i18n-inflector/util.rb
20
24
  lib/i18n-inflector/version.rb
21
25
  test/inflector_test.rb
22
26
  test/test_helper.rb
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = Simple Inflector for I18n
2
2
 
3
- <b>i18n-inflector version <tt>1.0</tt></b> (<b><tt>Aropsaid</tt></b>)
3
+ <b>i18n-inflector version <tt>2.0</tt></b> (<b><tt>Harvester</tt></b>)
4
4
 
5
5
 
6
6
 
@@ -8,23 +8,19 @@
8
8
  * https://github.com/siefca/i18n-inflector/tree
9
9
  * mailto:pw@gnu.org
10
10
 
11
- This library contains a backend module for I18n that adds some extra
12
- functionality to standard backend. It overwrites the translate method
13
- so that it will interpolate additional inflection tokens present in
14
- translations. These tokens may appear in *patterns* which are contained
15
- within <tt>@{</tt> and <tt>}</tt> symbols. Configuration is stored
16
- also in translation data, in a scope <tt><locale>.i18n.inflections</tt>,
17
- where <tt>locale</tt> is a locale subtree.
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
18
 
19
19
  You can choose different kinds (gender, title, person, time, author, etc.)
20
20
  of tokens to group them in a meaningful, semantical sets. That means you can
21
21
  apply Inflector to do simple inflection by a gender or a person, when some
22
22
  language requires it.
23
23
 
24
- It adds the +inflector+ object to the default backend so you can use many
25
- methods for accessing loaded inflection data at runtime, or set up global
26
- switches that are controlling the engine.
27
-
28
24
  Example translation data:
29
25
 
30
26
  en:
@@ -44,17 +40,20 @@ Example translation data:
44
40
  == Why?
45
41
 
46
42
  It's intended to be used in a web projects or other projects where
47
- translations are performed by many people, yet there is a need to
43
+ tranlations are performed by many people, yet there is a need to
48
44
  substitute fragments of text depending on user's gender, person or
49
45
  other data.
50
46
 
51
47
  To achieve similar functionality lambdas can be used but including
52
- proc objects in translations may be considered as unsafe.
48
+ proc objects in translations may be considered as the unsafe idea.
53
49
 
54
50
  If you have a troop of happy translators that shouldn't have the
55
51
  ability to execute any code yet you need some simple inflection
56
52
  then you should use this module.
57
53
 
54
+ See i18n-inflector-rails[https://rubygems.org/gems/i18n-inflector-rails] if
55
+ you need Rails integration.
56
+
58
57
  == Requirements
59
58
 
60
59
  * i18n[https://rubygems.org/gems/i18n]
@@ -83,27 +82,30 @@ then you should use this module.
83
82
 
84
83
  Detailed example:
85
84
 
86
- I18n.locale = :en
87
- I18n.backend.store_translations 'en', :i18n => { :inflections => {
88
- :gender => {
89
- :f => 'female',
90
- :m => 'male',
91
- :n => 'neuter',
92
- :default => 'n' }}}
85
+ ===== YAML:
86
+ en:
87
+ i18n:
88
+ inflections:
89
+ gender:
90
+ f: "female"
91
+ m: "male"
92
+ n: "neuter"
93
+ default: n
93
94
 
94
- I18n.backend.store_translations 'en', 'welcome' => 'Dear @{f:Lady|m:Sir|n:You|All}'
95
-
95
+ welcome: "Dear @{f:Lady|m:Sir|n:You|All}"
96
+
97
+ ===== Code:
96
98
  I18n.t('welcome')
97
99
  # => "Dear You"
98
100
 
99
- I18n.t('welcome', :gender => :m)
101
+ I18n.t('welcome', :gender => :male)
100
102
  # => "Dear Sir"
101
103
 
102
104
  I18n.t('welcome', :gender => :unknown)
103
- # => "Dear You"
105
+ # => "Dear All"
104
106
 
105
107
  I18n.t('welcome', :gender => nil)
106
- # => "Dear You"
108
+ # => "Dear All"
107
109
 
108
110
  == Tests
109
111
 
@@ -116,7 +118,9 @@ You can run tests both with
116
118
 
117
119
  See {whole documentation}[http://rubydoc.info/gems/i18n-inflector/] for more info about usage.
118
120
 
119
- See {I18n::Backend::Inflector} module documentation for detailed information.
121
+ See {I18n::Inflector} module documentation for information about API and detailed usage.
122
+
123
+ See {I18n::Backend::Inflector} module documentation for detailed information about internals.
120
124
 
121
125
  == See also
122
126
 
@@ -134,7 +138,7 @@ Copyright (c) 2011 by Paweł Wilk.
134
138
 
135
139
  i18n-inflector is copyrighted software owned by Paweł Wilk (pw@gnu.org).
136
140
  You may redistribute and/or modify this software as long as you
137
- comply with either the terms of the LGPL (see {file:LGPL-LICENSE}),
141
+ comply with either the terms of the LGPL (see {file:LGPL}),
138
142
  or Ruby's license (see {file:COPYING}).
139
143
 
140
144
  THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
  # -*- ruby -*-
3
-
3
+
4
4
  $:.unshift File.join(File.dirname(__FILE__), "lib")
5
5
 
6
6
  require 'rubygems'
@@ -41,16 +41,13 @@ Hoe.spec 'i18n-inflector' do
41
41
  self.rsync_args << '--chmod=a+rX'
42
42
  self.readme_file = 'README.rdoc'
43
43
  self.history_file = 'docs/HISTORY'
44
-
44
+
45
45
  extra_deps << ['i18n', '>= 0.4.1']
46
46
  extra_dev_deps << ['test_declarative', '>= 0.0.4'] <<
47
47
  ['yard', '>= 0.6.4'] <<
48
48
  ['bundler', '>= 1.0.7'] <<
49
- ['hoe-bundler', '>= 1.0.0']
50
-
51
- unless extra_dev_deps.flatten.include?('hoe-yard')
52
- extra_dev_deps << ['hoe-yard', '>= 0.1.2']
53
- end
49
+ ['hoe-bundler', '>= 1.0.0'] <<
50
+ ['hoe-yard', '>= 0.1.2']
54
51
  end
55
52
 
56
53
  task 'Manifest.txt' do
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.description = I18n::Inflector::DESCRIPTION
15
15
 
16
16
  s.files = Dir.glob("{ci,lib,spec,docs}/**/**") + %w(Gemfile .rspec .yardopts README.rdoc LGPL-LICENSE ChangeLog Manifest.txt)
17
- s.extra_rdoc_files = ["README.rdoc", "docs/TODO", "docs/HISTORY", "docs/LGPL-LICENSE", "docs/COPYING"]
17
+ s.extra_rdoc_files = ["README.rdoc", "docs/TODO", "docs/HISTORY", "docs/LGPL", "docs/COPYING"]
18
18
  s.rdoc_options = ["--main", "README.rdoc"]
19
19
  s.platform = Gem::Platform::RUBY
20
20
  s.require_path = 'lib'
@@ -22,11 +22,11 @@ Gem::Specification.new do |s|
22
22
  s.required_rubygems_version = '>= 1.3.5'
23
23
  s.specification_version = 3
24
24
 
25
- s.add_dependency 'i18n', '>= 0.5.0'
25
+ s.add_dependency 'i18n', '>= 0.4.1'
26
26
  s.add_development_dependency 'test_declarative', '>= 0.0.4'
27
27
  s.add_development_dependency 'rspec', '>= 2.3.0'
28
28
  s.add_development_dependency 'yard', '>= 1.0.7'
29
29
  s.add_development_dependency 'hoe-yard', '>= 0.1.2'
30
30
  s.add_development_dependency 'hoe-bundler', '>= 1.0.0'
31
-
31
+
32
32
  end
data/docs/COPYING CHANGED
@@ -1,4 +1,4 @@
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:LGPL-LICENSE LGPL-LICENSE}), or the conditions below ("Ruby License").
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:LGPL LGPL-LICENSE}), or the conditions below ("Ruby License").
2
2
 
3
3
  == 1.
4
4
 
data/docs/HISTORY CHANGED
@@ -1,3 +1,18 @@
1
+ === 2.0.0 / 2011-01-14
2
+
3
+ * major enhancements
4
+
5
+ * API changed
6
+ * Added a class for keeping internal inflection data: I18n::Inflector::InflectionData
7
+ * Added a class for keeping options: I18n::Inflector::InflectionOptions
8
+ * Added a class for controlling the inflection: I18n::Inflector::Core
9
+ * Added a module for utilities: I18n::Inflector::Util
10
+ * Added token groups support
11
+ * Added inversed matching of tokens in inflection patterns
12
+ * Added support for aliases in inflection patterns
13
+ * Most of the methods from I18n::Backend::Inflector moved to Core submodule
14
+ * Most methods rewritten
15
+
1
16
  === 1.0.10 / 2011-01-10
2
17
 
3
18
  * major bugfixes
@@ -47,7 +62,7 @@
47
62
  * major enhancements
48
63
 
49
64
  * YARD documentation updated with metatags
50
-
65
+
51
66
  * minor enhancements
52
67
 
53
68
  * Some changes in accessors for interpolation switches
data/docs/LEGAL CHANGED
@@ -6,6 +6,6 @@ i18n-inflector is Copyright (C) 2011 by Paweł Wilk.
6
6
  i18n-inflector is copyrighted software owned by Paweł Wilk
7
7
  (pw@gnu.org). You may redistribute and/or modify this
8
8
  software as long as you comply with either the terms of the LGPL
9
- (see the file {file:LGPL-LICENSE}),
9
+ (see the file {file:LGPL}),
10
10
  or Ruby's license (see the file {file:COPYING}).
11
11
 
File without changes
data/docs/RELATIONS ADDED
@@ -0,0 +1,25 @@
1
+ == This library contains
2
+
3
+ * Module {I18n::Inflector} containing everything
4
+ * Class {I18n::Inflector::Core} used to create inflector object attached to I18n backend
5
+ * Class {I18n::Inflector::InflectionData} used by {I18n::Inflector::Core} instances to store
6
+ inflection data and manipulate them, also is used by {I18n::Backend::Inflector} instances when loading
7
+ translations to create new database within {I18n::Inflector::Core} instance attachend to backend
8
+ * Class {I18n::Inflector::InflectionOptions} is used inside of {I18n::Inflector::Core} for keeping
9
+ switches and options
10
+ * Module {I18n::Backend::Inflector} used to alter methods of {I18n::Backend::Simple}
11
+
12
+ == Relations
13
+
14
+ * {I18n.backend} is the currently used backend and the instance of {I18n::Backend::Simple}
15
+ * {I18n.backend.inflector} is the instance of {I18n::Inflector::Core} attached to backend
16
+ * {I18n.inflector} is the proxy module method that calls inflector for currently used backend {I18n.backend.inflector}
17
+ * {I18n.backend.inflector.options} is the instance of {I18n::Inflector::InflectionOptions} and
18
+ mainly it controls a behavior of interpolation method
19
+ * {I18n::Inflector::Core} has an instance variable defined that contains database of translation data
20
+ * Each entry in the internal database of {I18n::Inflector::Core} is indexed by locale and is kind of
21
+ {I18n::Inflector::InflectionData}
22
+ * When initializing translations a method from {I18n::Backend::Simple} (altered by {I18n::Backend::Inflector})
23
+ takes the loaded data, processes the +i18n.inflections+ part for each locale and creates configuration
24
+ that is keeped as an instance of {I18n::Inflector::InflectionData}. That data is registered within the
25
+ inflecor object attached to backend that loaded the translations.