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.
- data/Changelog +4 -1
- data/Rakefile +2 -2
- data/lib/translations_sync.rb +26 -19
- metadata +4 -6
data/Changelog
CHANGED
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.
|
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
|
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
|
data/lib/translations_sync.rb
CHANGED
@@ -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
|
-
|
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
|
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.
|
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
|
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.
|
68
|
+
rubygems_version: 1.8.24
|
70
69
|
signing_key:
|
71
70
|
specification_version: 3
|
72
|
-
summary: Synchronizes the different locales represeinted in yaml
|
73
|
-
I18n
|
71
|
+
summary: Synchronizes the different locales represeinted in yaml for I18n
|
74
72
|
test_files: []
|