isomorfeus-i18n 2.3.0 → 2.3.1

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: c8b2deb16244e746673a70f916b59fd8216617144e9a46ed32d66ae97cee092a
4
- data.tar.gz: 9e503da185faa49cffbd73d343b6d09d7b6f61194cd5b498ba4b6e781a33c37a
3
+ metadata.gz: 318c106c4d432e8c87ed3336d9fe6b61d56f3e7518b59383f633811f9610dd73
4
+ data.tar.gz: cf914c20e1414875291d01fd3539404f48a07de8ee2308587a3fb65baab86a4e
5
5
  SHA512:
6
- metadata.gz: 2df8713260c351769d074d9c8cc644f2bbc5c4b1334077114f011e72a6ad7e9231e379afddc40014ec23c1e67decf37cd76041a0dd1548393da3f4131c4853d4
7
- data.tar.gz: 3ae93f1ed54c02971e5e1d14bc7d0720b3f1151545761415f2f7d53a005a9796c18286a73fd9f6e529312812f4fb938aeb0830709500294b01973e1706afb766
6
+ metadata.gz: d549ed7ba7f7c1542c258cc32e39163d614d628cea85649cd22755860bdff3cee4c8759479bddb58051d12edce8a9a7bc70bfe9521ee8e5aa9726cab20cc62db
7
+ data.tar.gz: 42a8a856829c3e61abf1a022e6fbd9f12c9b5e03a3cfefa55a93f6f5c075e012f5bd576708debd144058daf09cb9f0b82336ae4c0ec5f59b98ba57932e0ef6bd
@@ -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.3.0'
3
+ VERSION = '2.3.1'
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.3.0
4
+ version: 2.3.1
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-07 00:00:00.000000000 Z
11
+ date: 2022-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 10.6.60
117
+ version: 10.6.61
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.60
124
+ version: 10.6.61
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: isomorfeus-redux
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - '='
144
144
  - !ruby/object:Gem::Version
145
- version: 2.3.0
145
+ version: 2.3.1
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.3.0
152
+ version: 2.3.1
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.3.0
173
+ version: 2.3.1
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.3.0
180
+ version: 2.3.1
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