isomorfeus-i18n 2.2.11 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a766a5f8f69a26279f4750d89050e1a9285ba296a0ff440334249b8a83c203c1
4
- data.tar.gz: addedd74fb3ad1c9611b3526389582db6be1b00fd1f70b50646b47ba8cd016fc
3
+ metadata.gz: 4b85427fa741c03c88d6a6b82439277ee755dbd0163578f89e53079ed4bfd440
4
+ data.tar.gz: 46d95712c9720de30f56c3e5c707ec68a734503d862967eee44c02e848923e29
5
5
  SHA512:
6
- metadata.gz: 11920e09838738cc4db8d362b007b59d043ef9ac4ad3a2c6af4efb3bcf0f5a25bb06fab698b71e07c55ac8183dcbdc06d8d6d65b0e27e0514edecf2c39859e69
7
- data.tar.gz: b96d607374b3dbc2557b29603e5c3ffc47f9aab11b3c0dce5344729f31b22aef7466c7ad0d9b68439e93ff1a27d96b27ddd63bad2f48ff16d7f5f89c9adb8c09
6
+ metadata.gz: 06db6bb384207780a29db92f7764a044df06bf26c4793a7760ef042600af52b7573164a266e46a6ed99c503734e7f9b5cf5297b35a45dfd60b15589fa7e083b0
7
+ data.tar.gz: ad31218099011e3acb0c86293471a9d65b59354d981c02e0cde7ef6c806de89aa0a56048e1c7bcfcd180a09f8a3c260389573e39000f96426e3a5023bd99a988
@@ -0,0 +1,5 @@
1
+ class FastGettext::TranslationRepository::Base
2
+ def each(&block)
3
+ current_translations.each(&block)
4
+ end
5
+ end
@@ -0,0 +1,132 @@
1
+ module Isomorfeus
2
+ module I18n
3
+ class MissingKeys
4
+ def self.find
5
+ new.find
6
+ end
7
+
8
+ def initialize
9
+ Isomorfeus::I18n::Init.init
10
+ @locale_keys = {}
11
+ FastGettext.available_locales.each do |locale|
12
+ @locale_keys[locale] = Set.new
13
+ end
14
+ @all_keys = Set.new
15
+ @used_keys = Set.new
16
+ @all_files = Set.new
17
+ end
18
+
19
+ def find
20
+ # get keys for each locale
21
+ get_locale_keys
22
+ print_missing_locale_keys
23
+ get_used_keys
24
+ puts
25
+ print_missing_keys
26
+ puts
27
+ print_unused_keys
28
+ end
29
+
30
+ def get_locale_keys
31
+ FastGettext.translation_repositories.each_key do |domain|
32
+ FastGettext.available_locales.each do |locale|
33
+ FastGettext.locale = locale
34
+ FastGettext.translation_repositories[domain].each do |set|
35
+ @locale_keys[locale].add set[0]
36
+ @all_keys.add set[0]
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ def print_missing_locale_keys
43
+ puts "keys missing in locale:\n"
44
+ @all_keys.sort.each do |key|
45
+ ls = []
46
+ @locale_keys.each_key do |locale|
47
+ ls << locale unless @locale_keys[locale].include?(key)
48
+ end
49
+ unless ls.empty?
50
+ print "%-30s" % key
51
+ @locale_keys.each_key do |locale|
52
+ if ls.include?(locale)
53
+ print "\t#{locale}"
54
+ else
55
+ print "\t-"
56
+ end
57
+ end
58
+ print "\n"
59
+ end
60
+ end
61
+ end
62
+
63
+ def get_used_keys
64
+ collect_files(Isomorfeus.app_root)
65
+ @all_files.each do |file|
66
+ get_file_keys(file)
67
+ end
68
+ end
69
+
70
+ def get_file_keys(file)
71
+ contents = File.read(file)
72
+ contents.scan(/_\(\s*["':]([\w\-.]+)["']\s*\)/).each do |hit|
73
+ @used_keys.add(hit.first)
74
+ end
75
+ end
76
+
77
+ def print_missing_keys
78
+ puts "used keys missing in locale:"
79
+ @used_keys.sort.each do |key|
80
+ ls = []
81
+ @locale_keys.each_key do |locale|
82
+ ls << locale unless @locale_keys[locale]&.include?(key)
83
+ end
84
+ unless ls.empty?
85
+ print "%-30s" % key
86
+ @locale_keys.each_key do |locale|
87
+ if ls.include?(locale)
88
+ print "\t#{locale}"
89
+ else
90
+ print "\t-"
91
+ end
92
+ end
93
+ print "\n"
94
+ end
95
+ end
96
+ end
97
+
98
+ def print_unused_keys
99
+ puts "unused keys (may be used in variable keys):"
100
+ @all_keys.sort.each do |key|
101
+ unless @used_keys.include?(key)
102
+ ls = []
103
+ @locale_keys.each_key do |locale|
104
+ ls << locale if @locale_keys[locale]&.include?(key)
105
+ end
106
+ print "%-30s" % key
107
+ @locale_keys.each_key do |locale|
108
+ if ls.include?(locale)
109
+ print "\t#{locale}"
110
+ else
111
+ print "\t-"
112
+ end
113
+ end
114
+ print "\n"
115
+ end
116
+ end
117
+ end
118
+
119
+ def collect_files(dir)
120
+ d = Dir.open(dir)
121
+ d.each_child do |child|
122
+ child = File.expand_path(File.join(dir, child))
123
+ if Dir.exist?(child)
124
+ collect_files(child)
125
+ else
126
+ @all_files.add child if child.end_with?('.rb')
127
+ end
128
+ end
129
+ end
130
+ end
131
+ end
132
+ end
@@ -1,5 +1,5 @@
1
1
  module Isomorfeus
2
2
  module I18n
3
- VERSION = '2.2.11'
3
+ VERSION = '2.4.0'
4
4
  end
5
5
  end
@@ -18,7 +18,8 @@ else
18
18
  require 'oj'
19
19
  require 'r18n-core'
20
20
  require 'fast_gettext'
21
- require 'isomorfeus/fast_gettext_cache'
21
+ require 'isomorfeus/i18n/fast_gettext/cache'
22
+ require 'isomorfeus/i18n/fast_gettext/translation_repository/base'
22
23
  require 'http_accept_language/parser'
23
24
  require 'http_accept_language/middleware'
24
25
  require 'isomorfeus-data'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isomorfeus-i18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.11
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Biedermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-03 00:00:00.000000000 Z
11
+ date: 2022-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 1.4.1
75
+ version: 1.5.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 1.4.1
82
+ version: 1.5.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: opal-activesupport
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -100,56 +100,56 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.14.17
103
+ version: 0.14.22
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.14.17
110
+ version: 0.14.22
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: isomorfeus-preact
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 10.6.56
117
+ version: 10.7.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 10.6.56
124
+ version: 10.7.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: isomorfeus-redux
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 4.1.18
131
+ version: 4.2.0
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 4.1.18
138
+ version: 4.2.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: isomorfeus-transport
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - '='
144
144
  - !ruby/object:Gem::Version
145
- version: 2.2.11
145
+ version: 2.4.0
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - '='
151
151
  - !ruby/object:Gem::Version
152
- version: 2.2.11
152
+ version: 2.4.0
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: r18n-core
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -170,14 +170,14 @@ dependencies:
170
170
  requirements:
171
171
  - - '='
172
172
  - !ruby/object:Gem::Version
173
- version: 2.2.11
173
+ version: 2.4.0
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - '='
179
179
  - !ruby/object:Gem::Version
180
- version: 2.2.11
180
+ version: 2.4.0
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: rake
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -215,11 +215,13 @@ files:
215
215
  - LICENSE
216
216
  - README.md
217
217
  - lib/isomorfeus-i18n.rb
218
- - lib/isomorfeus/fast_gettext_cache.rb
219
218
  - lib/isomorfeus/i18n/config.rb
219
+ - lib/isomorfeus/i18n/fast_gettext/cache.rb
220
+ - lib/isomorfeus/i18n/fast_gettext/translation_repository/base.rb
220
221
  - lib/isomorfeus/i18n/handler/locale_handler.rb
221
222
  - lib/isomorfeus/i18n/init.rb
222
223
  - lib/isomorfeus/i18n/middleware.rb
224
+ - lib/isomorfeus/i18n/missing_keys.rb
223
225
  - lib/isomorfeus/i18n/reducer.rb
224
226
  - lib/isomorfeus/i18n/version.rb
225
227
  - lib/lucid_i18n/mixin.rb