tolk 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/tolk/locale.rb +6 -4
- data/lib/tolk/import.rb +1 -1
- data/lib/tolk/sync.rb +2 -2
- data/lib/tolk/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d28cc93fabb8286338fbdd1cd8715df10f4a76b1
|
4
|
+
data.tar.gz: 32cb9e4dc582a1d92091bb6a49f5b0dff1ac47bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf75b9e6e531e9eac234b348b0bcdfc709389d7236102e6fbf8d8f34c8a2707290d79f245a0f93f8c233874c5e0f0f8c28fc02d7e666b509b7edf4a00b16e969
|
7
|
+
data.tar.gz: 2a1d268fc7027215f7642e59857f9b0651b8af9adf3828db557dc03ae310a65e8f1eae7bfbe4fab5af39bf027bfb74928d2d2aed8a6d3f67155120b6fcab17eb
|
data/app/models/tolk/locale.rb
CHANGED
@@ -12,8 +12,8 @@ module Tolk
|
|
12
12
|
@dump_path ||= Tolk.config.dump_path.is_a?(Proc) ? instance_eval(&Tolk.config.dump_path) : Tolk.config.dump_path
|
13
13
|
end
|
14
14
|
|
15
|
-
has_many :phrases, :through => :translations, :class_name => 'Tolk::Phrase'
|
16
15
|
has_many :translations, :class_name => 'Tolk::Translation', :dependent => :destroy
|
16
|
+
has_many :phrases, :through => :translations, :class_name => 'Tolk::Phrase'
|
17
17
|
|
18
18
|
accepts_nested_attributes_for :translations, :reject_if => proc { |attributes| attributes['text'].blank? }
|
19
19
|
before_validation :remove_invalid_translations_from_target, :on => :update
|
@@ -36,6 +36,8 @@ module Tolk
|
|
36
36
|
cattr_accessor :special_keys
|
37
37
|
self.special_keys = ['activerecord.models']
|
38
38
|
|
39
|
+
PLURALIZATION_KEYS = ['none', 'zero', 'one', 'two', 'few', 'many', 'other']
|
40
|
+
|
39
41
|
class << self
|
40
42
|
def primary_locale(reload = false)
|
41
43
|
@_primary_locale = nil if reload
|
@@ -66,7 +68,7 @@ module Tolk
|
|
66
68
|
end
|
67
69
|
|
68
70
|
# http://cldr.unicode.org/index/cldr-spec/plural-rules - TODO: usage of 'none' isn't standard-conform
|
69
|
-
|
71
|
+
|
70
72
|
def pluralization_data?(data)
|
71
73
|
keys = data.keys.map(&:to_s)
|
72
74
|
keys.all? {|k| PLURALIZATION_KEYS.include?(k) }
|
@@ -90,7 +92,7 @@ module Tolk
|
|
90
92
|
end
|
91
93
|
|
92
94
|
def count_phrases_without_translation
|
93
|
-
existing_ids = self.translations
|
95
|
+
existing_ids = self.translations.pluck(&:phrase_id).uniq
|
94
96
|
Tolk::Phrase.count - existing_ids.count
|
95
97
|
end
|
96
98
|
|
@@ -101,7 +103,7 @@ module Tolk
|
|
101
103
|
def phrases_without_translation(page = nil)
|
102
104
|
phrases = Tolk::Phrase.all.order('tolk_phrases.key ASC')
|
103
105
|
|
104
|
-
existing_ids = self.translations(:
|
106
|
+
existing_ids = self.translations.pluck(:phrase_id).uniq
|
105
107
|
phrases = phrases.where('tolk_phrases.id NOT IN (?)', existing_ids) if existing_ids.present?
|
106
108
|
|
107
109
|
result = phrases.public_send(pagination_method, page)
|
data/lib/tolk/import.rb
CHANGED
@@ -49,7 +49,7 @@ module Tolk
|
|
49
49
|
|
50
50
|
def read_locale_file
|
51
51
|
locale_file = "#{self.locales_config_path}/#{self.name}.yml"
|
52
|
-
raise "Locale file #{locale_file} does not exists" unless File.
|
52
|
+
raise "Locale file #{locale_file} does not exists" unless File.exist?(locale_file)
|
53
53
|
|
54
54
|
puts "[INFO] Reading #{locale_file} for locale #{self.name}"
|
55
55
|
begin
|
data/lib/tolk/sync.rb
CHANGED
@@ -35,7 +35,7 @@ module Tolk
|
|
35
35
|
|
36
36
|
def read_primary_locale_file
|
37
37
|
primary_file = "#{self.locales_config_path}/#{self.primary_locale_name}.yml"
|
38
|
-
if File.
|
38
|
+
if File.exist?(primary_file)
|
39
39
|
flat_hash(Tolk::YAML.load_file(primary_file)[self.primary_locale_name])
|
40
40
|
else
|
41
41
|
{}
|
@@ -62,7 +62,7 @@ module Tolk
|
|
62
62
|
primary_locale = self.primary_locale
|
63
63
|
|
64
64
|
# Handle deleted phrases
|
65
|
-
translations.present? ? Tolk::Phrase.
|
65
|
+
translations.present? ? Tolk::Phrase.where(["tolk_phrases.key NOT IN (?)", translations.keys]).destroy_all : Tolk::Phrase.destroy_all
|
66
66
|
|
67
67
|
phrases = Tolk::Phrase.all
|
68
68
|
|
data/lib/tolk/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tolk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date:
|
15
|
+
date: 2017-06-14 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rails
|
@@ -20,14 +20,14 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: '
|
23
|
+
version: '5.0'
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
27
|
requirements:
|
28
28
|
- - ">="
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
version: '
|
30
|
+
version: '5.0'
|
31
31
|
- !ruby/object:Gem::Dependency
|
32
32
|
name: safe_yaml
|
33
33
|
requirement: !ruby/object:Gem::Requirement
|
@@ -48,14 +48,14 @@ dependencies:
|
|
48
48
|
requirements:
|
49
49
|
- - "~>"
|
50
50
|
- !ruby/object:Gem::Version
|
51
|
-
version: 2.
|
51
|
+
version: '2.14'
|
52
52
|
type: :development
|
53
53
|
prerelease: false
|
54
54
|
version_requirements: !ruby/object:Gem::Requirement
|
55
55
|
requirements:
|
56
56
|
- - "~>"
|
57
57
|
- !ruby/object:Gem::Version
|
58
|
-
version: 2.
|
58
|
+
version: '2.14'
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: sqlite3
|
61
61
|
requirement: !ruby/object:Gem::Requirement
|
@@ -85,7 +85,7 @@ dependencies:
|
|
85
85
|
- !ruby/object:Gem::Version
|
86
86
|
version: '1.0'
|
87
87
|
- !ruby/object:Gem::Dependency
|
88
|
-
name:
|
88
|
+
name: poltergeist
|
89
89
|
requirement: !ruby/object:Gem::Requirement
|
90
90
|
requirements:
|
91
91
|
- - ">="
|
@@ -171,7 +171,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
171
171
|
requirements:
|
172
172
|
- - ">="
|
173
173
|
- !ruby/object:Gem::Version
|
174
|
-
version: 2.
|
174
|
+
version: 2.2.2
|
175
175
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
176
|
requirements:
|
177
177
|
- - ">="
|
@@ -179,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
179
|
version: '0'
|
180
180
|
requirements: []
|
181
181
|
rubyforge_project:
|
182
|
-
rubygems_version: 2.
|
182
|
+
rubygems_version: 2.6.12
|
183
183
|
signing_key:
|
184
184
|
specification_version: 4
|
185
185
|
summary: Rails engine providing web interface for managing i18n yaml files
|