fast_gettext 2.0.1 → 2.2.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.
- checksums.yaml +4 -4
- data/CHANGELOG +1 -0
- data/LICENSE +78 -0
- data/Readme.md +7 -7
- data/lib/fast_gettext/storage.rb +1 -1
- data/lib/fast_gettext/translation_repository/base.rb +1 -1
- data/lib/fast_gettext/translation_repository/db.rb +2 -2
- data/lib/fast_gettext/version.rb +1 -1
- metadata +5 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70c22bbca4ca33f6445edaff4da234fb2c2a0b8a3ccc954d1f7353490fa63627
|
4
|
+
data.tar.gz: b04c5cfd44d7eb617d503dbd80beb88a69f35aa654fda00c560c86e5b209a940
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6ba6f8da19725a3a23ad7bd5d1bfdfe8bef6db6a3ab58fc5afea74625f4425d8313353c5f978df930acd132c46db467d55358513eaadcf24bdfe6c2c1b95fcb
|
7
|
+
data.tar.gz: 762e7fa657ea3cf1bc69cf2136db1121d811772dd540b680ff49a74e6f3f45f4bcefb0425ed734f4168b9c0ce0a590fd2a386b3f14194a5e5238f074dc65786e
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
2.1.0 -- Remove taint checking https://github.com/grosser/fast_gettext/pull/133
|
1
2
|
2.0.0 -- Changed p_ separator to \0004 https://github.com/grosser/fast_gettext/pull/107 add np and add gettext aliases
|
2
3
|
1.6.0 -- Remove restrictions around yaml file names
|
3
4
|
1.1.0 -- translations are no longer eager loaded for improved startup performance, pass `eager_load: true` to preload for example in preforked web server
|
data/LICENSE
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
Copyright (C) 2013 Michael Grosser <michael@grosser.it>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
# for lib/fast_gettext/vendor/*
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
|
23
|
+
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
|
24
|
+
You can redistribute it and/or modify it under either the terms of the
|
25
|
+
2-clause BSDL (see the file BSDL), or the conditions below:
|
26
|
+
|
27
|
+
1. You may make and give away verbatim copies of the source form of the
|
28
|
+
software without restriction, provided that you duplicate all of the
|
29
|
+
original copyright notices and associated disclaimers.
|
30
|
+
|
31
|
+
2. You may modify your copy of the software in any way, provided that
|
32
|
+
you do at least ONE of the following:
|
33
|
+
|
34
|
+
a) place your modifications in the Public Domain or otherwise
|
35
|
+
make them Freely Available, such as by posting said
|
36
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
37
|
+
the author to include your modifications in the software.
|
38
|
+
|
39
|
+
b) use the modified software only within your corporation or
|
40
|
+
organization.
|
41
|
+
|
42
|
+
c) give non-standard binaries non-standard names, with
|
43
|
+
instructions on where to get the original software distribution.
|
44
|
+
|
45
|
+
d) make other distribution arrangements with the author.
|
46
|
+
|
47
|
+
3. You may distribute the software in object code or binary form,
|
48
|
+
provided that you do at least ONE of the following:
|
49
|
+
|
50
|
+
a) distribute the binaries and library files of the software,
|
51
|
+
together with instructions (in the manual page or equivalent)
|
52
|
+
on where to get the original distribution.
|
53
|
+
|
54
|
+
b) accompany the distribution with the machine-readable source of
|
55
|
+
the software.
|
56
|
+
|
57
|
+
c) give non-standard binaries non-standard names, with
|
58
|
+
instructions on where to get the original software distribution.
|
59
|
+
|
60
|
+
d) make other distribution arrangements with the author.
|
61
|
+
|
62
|
+
4. You may modify and include the part of the software into any other
|
63
|
+
software (possibly commercial). But some files in the distribution
|
64
|
+
are not written by the author, so that they are not under these terms.
|
65
|
+
|
66
|
+
For the list of those files and their copying conditions, see the
|
67
|
+
file LEGAL.
|
68
|
+
|
69
|
+
5. The scripts and library files supplied as input to or produced as
|
70
|
+
output from the software do not automatically fall under the
|
71
|
+
copyright of the software, but belong to whomever generated them,
|
72
|
+
and may be sold commercially, and may be aggregated with this
|
73
|
+
software.
|
74
|
+
|
75
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
76
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
77
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
78
|
+
PURPOSE.
|
data/Readme.md
CHANGED
@@ -126,7 +126,7 @@ p_('File', 'Open') == _("File\004Open") == "öffnen"
|
|
126
126
|
p_('Context', 'not-found') == 'not-found'
|
127
127
|
```
|
128
128
|
|
129
|
-
#### `s_()` or `
|
129
|
+
#### `s_()` or `sgettext()`: translation with namespace
|
130
130
|
|
131
131
|
```ruby
|
132
132
|
s_('File|Open') == _('File|Open') == "öffnen"
|
@@ -153,13 +153,13 @@ sn_('Fruit|Apple', 'Apples', 1) == 'Apfel'
|
|
153
153
|
|
154
154
|
#### `N_()` and `Nn_()`: make dynamic translations available to the parser.
|
155
155
|
|
156
|
-
In many instances, your strings will not be found
|
156
|
+
In many instances, your strings will not be found by the ruby parsing. These methods
|
157
157
|
allow for those strings to be discovered.
|
158
158
|
|
159
159
|
```
|
160
160
|
N_("active"); N_("inactive"); N_("paused") # possible value of status for parser to find.
|
161
161
|
Nn_("active", "inactive", "paused") # alternative method
|
162
|
-
_("Your account is %{account_state}.") % { account_state: status }
|
162
|
+
_("Your account is %{account_state}.") % { account_state: _(status) }
|
163
163
|
```
|
164
164
|
|
165
165
|
|
@@ -180,7 +180,7 @@ Use the [original GetText](http://github.com/ruby-gettext/gettext) to create and
|
|
180
180
|
|
181
181
|
### Database
|
182
182
|
[Example migration for ActiveRecord](http://github.com/grosser/fast_gettext/blob/master/examples/db/migration.rb)<br/>
|
183
|
-
The default plural separator is `||||` but you may overwrite it (or suggest a better one
|
183
|
+
The default plural separator is `||||` but you may overwrite it (or suggest a better one...).
|
184
184
|
|
185
185
|
This is usable with any model DataMapper/Sequel or any other(non-database) backend, the only thing you need to do is respond to the self.translation(key, locale) call.
|
186
186
|
If you want to use your own models, have a look at the [default models](http://github.com/grosser/fast_gettext/tree/master/lib/fast_gettext/translation_repository/db_models) to see what you want/need to implement.
|
@@ -305,7 +305,7 @@ Unfound may not always mean missing, if you choose not to translate a word becau
|
|
305
305
|
A lambda or anything that responds to `call` will do as callback. A good starting point may be `examples/missing_translations_logger.rb`.
|
306
306
|
|
307
307
|
### Plugins
|
308
|
-
Want
|
308
|
+
Want an xml version?
|
309
309
|
Write your own TranslationRepository!
|
310
310
|
|
311
311
|
```Ruby
|
@@ -362,7 +362,7 @@ Alternatively you can use [merge repository](https://github.com/grosser/fast_get
|
|
362
362
|
|
363
363
|
#### Block defaults
|
364
364
|
|
365
|
-
All the translation methods (
|
365
|
+
All the translation methods (including MultiDomain) support a block default, a feature not provided by ruby-gettext. When a translation is
|
366
366
|
not found, if a block is provided the block is always returned. Otherwise, a key is returned. Methods doing pluralization will attempt a simple translation of alternate keys.
|
367
367
|
|
368
368
|
```ruby
|
@@ -422,4 +422,4 @@ Mo/Po-file parsing from Masao Mutoh, see vendor/README
|
|
422
422
|
[Michael Grosser](http://grosser.it)<br/>
|
423
423
|
michael@grosser.it<br/>
|
424
424
|
License: MIT, some vendor parts under the same license terms as Ruby (see headers)<br/>
|
425
|
-
[](https://github.com/grosser/fast_gettext/actions/workflows/actions.yml)
|
data/lib/fast_gettext/storage.rb
CHANGED
@@ -172,7 +172,7 @@ module FastGettext
|
|
172
172
|
locales = locales.to_s.gsub(/\s/, '')
|
173
173
|
found = [[]]
|
174
174
|
locales.split(',').each do |part|
|
175
|
-
if part
|
175
|
+
if part.include? ';q=' # contains language and weight ?
|
176
176
|
found.last << part.split(/;q=/)
|
177
177
|
found.last.flatten!
|
178
178
|
found << []
|
@@ -47,7 +47,7 @@ module FastGettext
|
|
47
47
|
Dir[File.join(path, '*')].each do |locale_folder|
|
48
48
|
next unless File.basename(locale_folder) =~ LOCALE_REX
|
49
49
|
|
50
|
-
file = File.join(locale_folder, relative_file_path)
|
50
|
+
file = File.join(locale_folder, relative_file_path)
|
51
51
|
next unless File.exist? file
|
52
52
|
|
53
53
|
locale = File.basename(locale_folder)
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'active_record'
|
4
3
|
module FastGettext
|
5
4
|
module TranslationRepository
|
6
5
|
# Responsibility:
|
@@ -31,7 +30,7 @@ module FastGettext
|
|
31
30
|
end
|
32
31
|
|
33
32
|
def pluralisation_rule
|
34
|
-
@model.
|
33
|
+
@model.pluralisation_rule if @model.respond_to? :pluralisation_rule
|
35
34
|
end
|
36
35
|
|
37
36
|
def [](key)
|
@@ -51,6 +50,7 @@ module FastGettext
|
|
51
50
|
end
|
52
51
|
|
53
52
|
def self.require_models
|
53
|
+
require 'active_record'
|
54
54
|
folder = "fast_gettext/translation_repository/db_models"
|
55
55
|
require "#{folder}/translation_key"
|
56
56
|
require "#{folder}/translation_text"
|
data/lib/fast_gettext/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fast_gettext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -94,20 +94,6 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: wwtd
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
98
|
name: rubocop
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -157,6 +143,7 @@ extensions: []
|
|
157
143
|
extra_rdoc_files: []
|
158
144
|
files:
|
159
145
|
- CHANGELOG
|
146
|
+
- LICENSE
|
160
147
|
- Readme.md
|
161
148
|
- lib/fast_gettext.rb
|
162
149
|
- lib/fast_gettext/cache.rb
|
@@ -195,15 +182,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
195
182
|
requirements:
|
196
183
|
- - ">="
|
197
184
|
- !ruby/object:Gem::Version
|
198
|
-
version: 2.
|
185
|
+
version: 2.5.0
|
199
186
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
200
187
|
requirements:
|
201
188
|
- - ">="
|
202
189
|
- !ruby/object:Gem::Version
|
203
190
|
version: '0'
|
204
191
|
requirements: []
|
205
|
-
|
206
|
-
rubygems_version: 2.7.6
|
192
|
+
rubygems_version: 3.1.6
|
207
193
|
signing_key:
|
208
194
|
specification_version: 4
|
209
195
|
summary: A simple, fast, memory-efficient and threadsafe implementation of GetText
|