fast_gettext 2.0.0 → 2.1.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91bc0d49ead2bfbfad8065858e52255dfcd9938cb547f0b20984bb12cc202380
|
4
|
+
data.tar.gz: 45c2e546d2041e36b82a4d82593d4b1c014d46da561996037a76d6e911ed2cdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1120024578b173fb99e2bf879b22654723efede889a98d7d950c8201aef11261566f6c70a6247f8ce937fef9f7ec88fe1a6dc9a874331e6cc41fbed55cc651f2
|
7
|
+
data.tar.gz: 6cdbf2dcec813b6fb0c0da4b87af33c372a2f87ea177fdafd0203cf3f45f565a5fe64b4e41fe4fedcd4450ec1a7196d4c5a015df35470b4cfdb8b21e4037b137
|
data/Readme.md
CHANGED
@@ -95,8 +95,8 @@ FastGettext.locale = 'de'
|
|
95
95
|
|
96
96
|
### 4. Start translating
|
97
97
|
|
98
|
-
|
99
|
-
(to get `*gettext` methods, use `
|
98
|
+
FastGettext supports all the translation methods of [ruby-gettext](http://github.com/ruby-gettext/gettext) with added support for block defaults.
|
99
|
+
(to get `*gettext` methods, use `FastGettext::TranslationAliased`)
|
100
100
|
|
101
101
|
#### `_()` or `gettext()`: basic translation
|
102
102
|
|
@@ -116,7 +116,7 @@ n_('Car', 'Cars', 2) == 'Autos' # German plural of Cars
|
|
116
116
|
You'll often want to interpolate the results of `n_()` using ruby builtin `%` operator.
|
117
117
|
|
118
118
|
```ruby
|
119
|
-
n_('Car', '
|
119
|
+
n_('Car', '%{n} Cars', 2) % { n: count } == '2 Autos'
|
120
120
|
```
|
121
121
|
|
122
122
|
#### `p_()` or `pgettext()`: translation with context
|
@@ -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
|
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/mo_file.rb
CHANGED
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.
|
4
|
+
version: 2.1.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: 2021-08-27 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
|
@@ -195,15 +181,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
195
181
|
requirements:
|
196
182
|
- - ">="
|
197
183
|
- !ruby/object:Gem::Version
|
198
|
-
version: 2.
|
184
|
+
version: 2.5.0
|
199
185
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
200
186
|
requirements:
|
201
187
|
- - ">="
|
202
188
|
- !ruby/object:Gem::Version
|
203
189
|
version: '0'
|
204
190
|
requirements: []
|
205
|
-
|
206
|
-
rubygems_version: 2.7.6
|
191
|
+
rubygems_version: 3.2.16
|
207
192
|
signing_key:
|
208
193
|
specification_version: 4
|
209
194
|
summary: A simple, fast, memory-efficient and threadsafe implementation of GetText
|