transdifflation 0.0.2 → 0.0.3
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/Fudgefile +1 -1
- data/Gemfile +1 -1
- data/README.md +16 -3
- data/Rakefile +8 -1
- data/lib/tasks/lost_in_translation.rake +31 -2
- data/lib/tasks/translation_coverage.rake +29 -4
- data/lib/transdifflation/transdifflation.yml +3 -2
- data/lib/transdifflation/version.rb +1 -1
- metadata +2 -2
data/Fudgefile
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -54,6 +54,11 @@ grouped_tasks:
|
|
54
54
|
task_group_name:
|
55
55
|
- task_name1
|
56
56
|
- task_name2
|
57
|
+
|
58
|
+
ignore_paths:
|
59
|
+
- /path_one
|
60
|
+
- gem_path
|
61
|
+
|
57
62
|
```
|
58
63
|
|
59
64
|
These nodes generates rake tasks. There are two types of tasks:
|
@@ -77,9 +82,17 @@ There are two new tasks in the town:
|
|
77
82
|
|
78
83
|
These tasks are intended to be used to know what keys are missing between two locales. ```rake transdifflation:lost_in_translation[from_locale,to_locale]``` creates a file in ```[Rails.root]/config/locales/[from_locale]/missing_translations.yml.diff```(on YAML format), that you can use as a template to fulfill your translation.
|
79
84
|
|
80
|
-
```rake transdifflation:lost_in_translation_ci[from_locale,to_locale]```
|
85
|
+
```rake transdifflation:lost_in_translation_ci[from_locale,to_locale]```
|
86
|
+
doesn't create a file, it just fails if missing translations needed, so
|
87
|
+
you can use it in a continuous integration environment, if you want to
|
88
|
+
test that your translations are always completed between your third
|
89
|
+
party gems' new versions, or other vendor's project new releases, or
|
90
|
+
stuff like that... You can configure ignore_paths to ignore whatever gem
|
91
|
+
you don't what to check
|
81
92
|
|
82
|
-
```rake transdifflation:coverage[from_locale,to_locale]``` gives you
|
93
|
+
```rake transdifflation:coverage[from_locale,to_locale]``` gives you
|
94
|
+
information and statistics of translations. You can configure
|
95
|
+
ignore_paths too.
|
83
96
|
|
84
97
|
|
85
98
|
|
@@ -90,4 +103,4 @@ These tasks are intended to be used to know what keys are missing between two lo
|
|
90
103
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
91
104
|
3. Commit your changes (`git commit -am 'Added some feature'`)
|
92
105
|
4. Push to the branch (`git push origin my-new-feature`)
|
93
|
-
5. Create new Pull Request
|
106
|
+
5. Create new Pull Request
|
data/Rakefile
CHANGED
@@ -2,4 +2,11 @@
|
|
2
2
|
require 'bundler/gem_tasks'
|
3
3
|
require 'rspec/core/rake_task'
|
4
4
|
Dir['lib/tasks/*'].each { |f| load f }
|
5
|
-
RSpec::Core::RakeTask.new('spec')
|
5
|
+
RSpec::Core::RakeTask.new('spec')
|
6
|
+
|
7
|
+
task :default => :fudge
|
8
|
+
|
9
|
+
# Test Fudge using Fudge
|
10
|
+
task :fudge do
|
11
|
+
exec 'fudge build'
|
12
|
+
end
|
@@ -6,7 +6,36 @@ namespace :transdifflation do
|
|
6
6
|
def get_differences (from_locale, to_locale)
|
7
7
|
|
8
8
|
#this will access translations method, that is protected in BackEnd in I18n
|
9
|
-
|
9
|
+
|
10
|
+
#Reading config file
|
11
|
+
search_locations = %w[config/transdifflation.yml transdifflation.yml]
|
12
|
+
|
13
|
+
|
14
|
+
file_task_config = nil
|
15
|
+
search_locations.each do |path| #Take config file from these locations
|
16
|
+
abs_path = File.expand_path(path, Rails.root)
|
17
|
+
if(File.exists?(abs_path))
|
18
|
+
file_task_config = abs_path
|
19
|
+
break
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
raise Transdifflation::ConfigFileNotFound if file_task_config.nil?
|
24
|
+
|
25
|
+
paths_ignored = YAML.load_file(file_task_config).symbolize![:ignore_paths]
|
26
|
+
|
27
|
+
if paths_ignored
|
28
|
+
I18n.reload!
|
29
|
+
paths_ignored.each {|ignored |
|
30
|
+
I18n.load_path.delete_if {|p| p.include?(ignored)}
|
31
|
+
}
|
32
|
+
I18n.backend.load_translations
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
translations = I18n.backend.send(:translations) #Now is nil {}
|
37
|
+
# do something with /Faker-/ to remove all Faker yamls from the backend
|
38
|
+
|
10
39
|
hash_from_locale = translations[from_locale]
|
11
40
|
hash_to_locale = translations[to_locale]
|
12
41
|
|
@@ -56,4 +85,4 @@ namespace :transdifflation do
|
|
56
85
|
|
57
86
|
|
58
87
|
|
59
|
-
end
|
88
|
+
end
|
@@ -5,13 +5,39 @@ namespace :transdifflation do
|
|
5
5
|
|
6
6
|
def get_coverage_rate(from_locale, to_locale)
|
7
7
|
#this will access translations method, that is protected in BackEnd in I18n
|
8
|
-
|
8
|
+
|
9
|
+
#Reading config file
|
10
|
+
search_locations = %w[config/transdifflation.yml transdifflation.yml]
|
11
|
+
|
12
|
+
|
13
|
+
file_task_config = nil
|
14
|
+
search_locations.each do |path| #Take config file from these locations
|
15
|
+
abs_path = File.expand_path(path, Rails.root)
|
16
|
+
if(File.exists?(abs_path))
|
17
|
+
file_task_config = abs_path
|
18
|
+
break
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
raise Transdifflation::ConfigFileNotFound if file_task_config.nil?
|
23
|
+
|
24
|
+
paths_ignored = YAML.load_file(file_task_config).symbolize![:ignore_paths]
|
25
|
+
|
26
|
+
if paths_ignored
|
27
|
+
I18n.reload!
|
28
|
+
paths_ignored.each {|ignored |
|
29
|
+
I18n.load_path.delete_if {|p| p.include?(ignored)}
|
30
|
+
}
|
31
|
+
I18n.backend.load_translations
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
|
9
36
|
hash_from_locale = translations[from_locale]
|
10
37
|
hash_to_locale = translations[to_locale]
|
11
38
|
|
12
39
|
comparer = Transdifflation::Comparer.new
|
13
40
|
comparer.coverage_rate(hash_from_locale, hash_to_locale)
|
14
|
-
|
15
41
|
end
|
16
42
|
|
17
43
|
desc "A task to check a translation coverage"
|
@@ -25,9 +51,8 @@ namespace :transdifflation do
|
|
25
51
|
|
26
52
|
differences = get_coverage_rate(from_locale, to_locale)
|
27
53
|
puts "You have #{differences}"
|
28
|
-
|
29
54
|
end
|
30
55
|
|
31
56
|
|
32
57
|
|
33
|
-
end
|
58
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: transdifflation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|