tidy_i18n 0.0.4 → 0.0.5

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MjU4ZWY4M2VmMGNlMDJjOGNjZWU2OTRiYTI1ZGQ0YmY4ZDdiYmViZA==
4
+ NWIxODcyNTI4ODI0NDgyZGM5MWQ2ODI1ZjVhZmJlOGVmMWJkY2FjOA==
5
5
  data.tar.gz: !binary |-
6
- ZWViYmQ5MDRhZmFkYWM1ODNiMzQ3NWU5NzYwYjgyZGQxYWI0MmY4YQ==
6
+ NThkZTY0MzlmNDc1NTgxOTUyMjYyNzg2ZGU0M2FmOGFjZTEwMjk4Mg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MWVjNzc3N2M0MzliMTkyMTliMWU3ZWEyYzRhNzNmNWViYTAwNDE3NzgzYWRh
10
- ZTYwOWQyZGJkMzI2ZGZkNzRmZmE4MGJjYmIzOWZlZjFkZDUzMTFlOGU1MmFh
11
- M2RjNDU5OGQ5MmZkOGM0YWFjYjY3YjA4ZjU2ZDVmMWQ3ODIxN2U=
9
+ NGJlYjI3MTAxODFjNDU1NzJkODIyYWQwNDE2MWZiNmIyNTcwNTgyNzdlZTk3
10
+ YjhlM2IyNGU0ZWI2MDQ2ZjUzYTYwYTc4ZTZjMDI5NmIzNDEzNTUwYTE3YzM5
11
+ ODU1NGQ5ZGQ4MzRmM2EyNjE5ZDAyNTVkZmY1ZWIyM2U2NzI3MmI=
12
12
  data.tar.gz: !binary |-
13
- MDQ0YjZkYTlhMGQ2MDg2NTEwMjE1OGM2Zjg3YWI2MTBhZTA2MDdiZTQ2NDQ1
14
- MzY1OGZkMTI2NGMyOTMyZmUzMWUyM2VjYmUzZjI0ODI5NjI0NmI1M2JlZDc4
15
- ZGNhODliZjIxY2EzOWU4MjRkZThhNmNhNTFmMGE4MDMzOTkzNzY=
13
+ ODBjY2UzNGQ5ZjFmYzBlM2E3YTNmY2ZhMzc5NGYxODdmMTNjYmQ3YzE5NWMy
14
+ MGRhMjcyOGFjNDI5MmQ2NDgxMmE4MTMyZmRmNjNjNjliYTI2YzBkZmJkYzk0
15
+ YzhmOWIwODQ3Mzg5MWQzNzJkMmRkZGJiN2QyZTRiYjQ0MjAyYTk=
@@ -0,0 +1,51 @@
1
+ require "tidy_i18n/translation_keys"
2
+ require "ostruct"
3
+
4
+ module TidyI18n
5
+ class DuplicateKeys
6
+
7
+ attr_reader :locale
8
+
9
+ def initialize(locale, locale_file_paths)
10
+ self.locale = locale
11
+ self.locale_file_paths = locale_file_paths
12
+ end
13
+
14
+ def all
15
+ wat = translation_keys_for_current_locale.group_by(&:name).values
16
+ less = wat.select do |occurrences|
17
+ occurrences.count > 1
18
+ end.collect do |occurrences|
19
+ OpenStruct.new({
20
+ :name => occurrences.first.name.sub(/^#{locale}\./, ""),
21
+ :values => occurrences.collect(&:value)
22
+ })
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def translation_keys_for_current_locale
29
+ all_translation_keys.fetch(locale.to_s, [])
30
+ end
31
+
32
+ def all_translation_keys
33
+ locale_file_paths.each.with_object({}) do |locale_file_path, locale_to_keys|
34
+ keys = TidyI18n::TranslationKeys.parse(File.read(locale_file_path))
35
+ if keys.any?
36
+ current_locale = keys.first.name.split(".").first
37
+ locale_to_keys[current_locale.to_s] = keys.collect do |key|
38
+ OpenStruct.new({
39
+ :name => key.name.sub(/^#{current_locale}\./, ""),
40
+ :value => key.value
41
+ })
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ attr_accessor :locale_file_paths
48
+ attr_writer :locale
49
+
50
+ end
51
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tidy_i18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Meyer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-04 00:00:00.000000000 Z
11
+ date: 2014-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -32,6 +32,7 @@ extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
34
  - lib/tidy_i18n/dictionary_converter.rb
35
+ - lib/tidy_i18n/duplicate_keys.rb
35
36
  - lib/tidy_i18n/locales/reverse.rb
36
37
  - lib/tidy_i18n/locales/tilde.rb
37
38
  - lib/tidy_i18n/locales.rb