translations_sync 0.3.1 → 0.4.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.
Files changed (4) hide show
  1. data/Changelog +4 -1
  2. data/Rakefile +2 -2
  3. data/lib/translations_sync.rb +26 -19
  4. metadata +4 -6
data/Changelog CHANGED
@@ -1,4 +1,7 @@
1
- 2012-09-19 v.0.3.1
1
+ 2012-09-17 v.0.4.0
2
+ * Bugfix with proper calculation of count keys + transliteration screening
3
+
4
+ 2012-09-16 v.0.3.1
2
5
  * Rakfile should not be copied if using rails. Do not forget to remove the old one!
3
6
 
4
7
  2011-08-19 v.0.3.0
data/Rakefile CHANGED
@@ -6,11 +6,11 @@ require 'rubygems/specification'
6
6
  require 'date'
7
7
 
8
8
  GEM = "translations_sync"
9
- GEM_VERSION = "0.3.1"
9
+ GEM_VERSION = "0.4.0"
10
10
  AUTHOR = "Dmitri Koulikoff"
11
11
  EMAIL = "koulikoff@gmail.com"
12
12
  HOMEPAGE = "http://github.com/dima4p/translations_sync/"
13
- SUMMARY = "Synchronizes the different locales represeinted in yaml, in particular, for I18n"
13
+ SUMMARY = "Synchronizes the different locales represeinted in yaml for I18n"
14
14
 
15
15
  spec = Gem::Specification.new do |s|
16
16
  s.name = GEM
@@ -56,35 +56,19 @@ class TranslationsSync
56
56
 
57
57
  def initialize(list = nil, exclude = nil, source = nil)
58
58
  I18n.backend.send(:init_translations) unless I18n.backend.initialized?
59
- @translations = I18n.backend.send :translations
60
- if source
61
- re = Regexp.new "\\/#{Regexp.escape source}_[a-z]{2}(-[A-Z]{2})?\\.(yml|rb)\\Z"
62
- I18n.load_path.reject! do |path|
63
- path !~ re
64
- end
65
- @translations.each do |key, hash|
66
- hash.keys.each do |k|
67
- hash.delete(k) unless k == :pluralize
68
- end
69
- end
70
- I18n.backend.send(:init_translations)
71
- end
59
+ translations = I18n.backend.send :translations
72
60
  @full_list = ((list || DEFAULT_LIST).split(',').map(&:to_sym) + translations.keys).uniq
73
61
  exclude = (exclude || EXCLUDE_LIST).split(',').map(&:to_sym)
74
62
  @list = @full_list - exclude
75
- @flat = {}
76
- @list.each do |lang|
77
- flatten_keys(lang, translations[lang] || {}, @flat)
78
- end
79
63
  rules_key = %w[i18n.plural.rule pluralize].detect do |rule|
80
64
  @list.detect do |lang|
81
65
  locale_pluralize = I18n.backend.send(:lookup, lang, rule) and
82
66
  locale_pluralize.respond_to?(:call)
83
67
  end
84
68
  end
85
- @flat.delete(rules_key.split('.').map(&:to_sym)) # we do not need this proc if it exists
86
69
  @pluralize_keys = @list.inject({}) do |acc, lang|
87
- acc[lang] = if locale_pluralize = I18n.backend.send(:lookup, lang, rules_key) and
70
+ acc[lang] = if rules_key and
71
+ locale_pluralize = I18n.backend.send(:lookup, lang, rules_key) and
88
72
  locale_pluralize.respond_to?(:call)
89
73
  ((0..100).map do |n|
90
74
  locale_pluralize.call n
@@ -94,6 +78,29 @@ class TranslationsSync
94
78
  end
95
79
  acc
96
80
  end
81
+
82
+ if source
83
+ re = Regexp.new "\\/#{Regexp.escape source}_[a-z]{2}(-[A-Z]{2})?\\.(yml|rb)\\Z"
84
+ I18n.load_path.reject! do |path|
85
+ path !~ re
86
+ end
87
+ translations.each do |key, hash|
88
+ hash.keys.each do |k|
89
+ hash.delete(k) unless k == :pluralize
90
+ end
91
+ end
92
+ I18n.backend.send(:init_translations)
93
+ end
94
+
95
+ @flat = {}
96
+ @list.each do |lang|
97
+ flatten_keys(lang, translations[lang] || {}, @flat)
98
+ end
99
+ @flat.delete(rules_key.split('.').map(&:to_sym)) # we do not need this proc if it exists
100
+ transliterate = [:i18n, :transliterate]
101
+ @flat.keys.select do |key|
102
+ @flat.delete(key) if key[0..1] == transliterate
103
+ end
97
104
  end
98
105
 
99
106
  def locales_with_missing
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: translations_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -27,8 +27,7 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
- description: Synchronizes the different locales represeinted in yaml, in particular,
31
- for I18n
30
+ description: Synchronizes the different locales represeinted in yaml for I18n
32
31
  email: koulikoff@gmail.com
33
32
  executables:
34
33
  - translations_sync
@@ -66,9 +65,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
65
  version: '0'
67
66
  requirements: []
68
67
  rubyforge_project:
69
- rubygems_version: 1.8.19
68
+ rubygems_version: 1.8.24
70
69
  signing_key:
71
70
  specification_version: 3
72
- summary: Synchronizes the different locales represeinted in yaml, in particular, for
73
- I18n
71
+ summary: Synchronizes the different locales represeinted in yaml for I18n
74
72
  test_files: []