lost_in_translation 0.2.16 → 0.2.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +2 -1
- data/lib/{lost_in_translation → lit}/difference.rb +0 -0
- data/lib/{lost_in_translation → lit}/file_functions.rb +0 -0
- data/lib/{lost_in_translation → lit}/hash.rb +0 -0
- data/lib/{lost_in_translation/railtie.rb → lit/railties.rb} +2 -3
- data/lib/{lost_in_translation → lit}/user_interface.rb +31 -4
- data/lib/lost_in_translation.rb +34 -14
- data/lib/{lost_in_translation/z_interactive.rb → tasks/compare.rb} +8 -26
- data/lib/tasks/count.rb +22 -0
- data/lib/{lost_in_translation/z_cleanup.rb → tasks/delete_missing.rb} +4 -13
- data/lib/tasks/fully_automatic.rb +32 -0
- data/lib/tasks/half_automatic.rb +32 -0
- data/lib/tasks/joke.rb +11 -0
- data/lib/{lost_in_translation/z_recent.rb → tasks/recent.rb} +8 -23
- data/lib/tasks/sort_file.rb +25 -0
- data/lib/tasks/split_file.rb +37 -0
- data/lib/tasks/start.rb +16 -0
- data/lib/tasks/tasks.rake +49 -0
- data/lost_in_translation.gemspec +1 -2
- metadata +18 -15
- data/.rubocop.yml +0 -28
- data/lib/lost_in_translation/version.rb +0 -6
- data/lib/lost_in_translation/z_full_automatic.rb +0 -30
- data/lib/lost_in_translation/z_half_automatic.rb +0 -33
- data/lib/tasks/lit.rake +0 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ad42c6951dfd14e714e28bdbaba80b1451ceddf
|
4
|
+
data.tar.gz: c8dbcbc3f973cdde9efe3ada5ebb7b4ebd958497
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d234d08dd85289eb6919666d504650640e4e961b61fe334efa45cfdcc67982221872d038b6aa22894115fe8bcf637490cbc2d1c7c8dc9dc20ba6d66cb6bfa2b
|
7
|
+
data.tar.gz: 9b47b20a64c9e453461b0f989422cbb4b35d8b0269b8004b703e2b628b3d6482e0355c3d308c1ced11db52a774d04619713203b041f32d552546a54c318979ea
|
data/Rakefile
CHANGED
File without changes
|
File without changes
|
File without changes
|
@@ -1,14 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'lost_in_translation'
|
4
3
|
require 'rails'
|
4
|
+
|
5
5
|
module LostInTranslation
|
6
|
-
#
|
7
6
|
class Railtie < Rails::Railtie
|
8
7
|
railtie_name :lost_in_translation
|
9
8
|
|
10
9
|
rake_tasks do
|
11
|
-
load 'tasks/
|
10
|
+
load 'tasks/tasks.rake'
|
12
11
|
end
|
13
12
|
end
|
14
13
|
end
|
@@ -5,13 +5,17 @@ module LostInTranslation
|
|
5
5
|
require 'readline'
|
6
6
|
|
7
7
|
def self.ask_for_file(master)
|
8
|
-
text = master ? "# Master (e.g. 'en'): " : "# Slave: (e.g. 'de'): "
|
8
|
+
text = master ? "# Master (e.g. 'en', 'namespace.en'): " : "# Slave: (e.g. 'de', 'namespace.de'): "
|
9
9
|
file = {}
|
10
|
-
file[:
|
11
|
-
file[:
|
12
|
-
|
10
|
+
file[:filename] = [(print text), Readline.readline()][1]
|
11
|
+
file[:lang] = file[:filename].split('.').last
|
12
|
+
file[:path] = defined?(Rails) ? "#{Rails.root}/config/locales/#{file[:filename]}.yml" : ask_for_path
|
13
|
+
if !File.exist?(file[:path]) && master
|
13
14
|
log "File #{file[:path]} not found!"
|
14
15
|
file[:path] = ask_for_path
|
16
|
+
elsif !File.exist?(file[:path]) && !master
|
17
|
+
log "File #{file[:filename]} not found! It will be created!"
|
18
|
+
File.open(file[:path], 'w') { |f| f.write({ file[:lang] => {} }.to_yaml(line_width: -1)) }
|
15
19
|
end
|
16
20
|
file[:app_name] = Rails&.application&.class&.parent_name
|
17
21
|
file
|
@@ -28,6 +32,29 @@ module LostInTranslation
|
|
28
32
|
a == 'y' || a == 'Y' || a == ''
|
29
33
|
end
|
30
34
|
|
35
|
+
def self.ask_for_task(tasks)
|
36
|
+
log
|
37
|
+
log 'Welcome, stranger!'
|
38
|
+
log 'Are you lost in translation, too?'
|
39
|
+
log 'Then I will be glad to help you one of the following tasks!'
|
40
|
+
tasks.each_with_index do |task, i|
|
41
|
+
log "#{i + 1}. | #{task[:text]}"
|
42
|
+
end
|
43
|
+
log 'Soo ... what can I do for you? (Type in the Number)'
|
44
|
+
id = [(print 'Task No.: '), Readline.readline()][1]
|
45
|
+
tasks[(id.to_i - 1)]
|
46
|
+
rescue
|
47
|
+
puts "Cannot find task with id #{id}"
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.ask_for_split(lang, count)
|
51
|
+
log
|
52
|
+
log "Splitting File #{lang}.yml"
|
53
|
+
log "File-Count: #{count} new files will be create!"
|
54
|
+
a = [(print "# Wanna do it? [Y/n]: "), Readline.readline()][1]
|
55
|
+
a == 'y' || a == 'Y' || a == ''
|
56
|
+
end
|
57
|
+
|
31
58
|
def self.ask_for_sorting(lang, app_name)
|
32
59
|
log
|
33
60
|
log "Application: #{app_name}"
|
data/lib/lost_in_translation.rb
CHANGED
@@ -1,18 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require '
|
5
|
-
require '
|
6
|
-
require '
|
7
|
-
require '
|
8
|
-
|
9
|
-
require '
|
10
|
-
require '
|
11
|
-
require '
|
12
|
-
require '
|
13
|
-
require '
|
14
|
-
|
15
|
-
|
3
|
+
require 'lit/difference'
|
4
|
+
require 'lit/file_functions'
|
5
|
+
require 'lit/hash'
|
6
|
+
require 'lit/user_interface'
|
7
|
+
require 'lit/railties'
|
8
|
+
|
9
|
+
require 'tasks/compare'
|
10
|
+
require 'tasks/delete_missing'
|
11
|
+
require 'tasks/fully_automatic'
|
12
|
+
require 'tasks/half_automatic'
|
13
|
+
require 'tasks/recent'
|
14
|
+
require 'tasks/sort_file'
|
15
|
+
require 'tasks/split_file'
|
16
|
+
require 'tasks/start'
|
17
|
+
require 'tasks/count'
|
18
|
+
require 'tasks/joke'
|
19
|
+
|
16
20
|
module LostInTranslation
|
17
21
|
def self.root
|
18
22
|
File.dirname __dir__
|
@@ -25,9 +29,25 @@ module LostInTranslation
|
|
25
29
|
tmp_paths[:slave] = "#{root}/tmp/tmp_slave.yml"
|
26
30
|
tmp_paths
|
27
31
|
end
|
32
|
+
|
33
|
+
def self.init(with_slave = true)
|
34
|
+
system 'clear'
|
35
|
+
log
|
36
|
+
log 'What I18n-yaml files do you want to compare?'
|
37
|
+
master = ask_for_file(true) # lang path app_name
|
38
|
+
slave = with_slave ? ask_for_file(false) : {}
|
39
|
+
raise InvalidFilepaths if !File.exist?(master[:path]) && (!File.exist?(slave[:path]) && with_slave)
|
40
|
+
[master, slave, tmp_paths]
|
41
|
+
end
|
28
42
|
end
|
29
43
|
|
30
|
-
#
|
31
44
|
class Lit
|
32
45
|
extend LostInTranslation
|
33
46
|
end
|
47
|
+
|
48
|
+
class InvalidFilepaths
|
49
|
+
end
|
50
|
+
|
51
|
+
class Breakup
|
52
|
+
# puts 'Well, in that case, forget it!'
|
53
|
+
end
|
@@ -1,19 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
3
|
module LostInTranslation
|
5
|
-
def self.
|
6
|
-
|
7
|
-
log
|
8
|
-
log 'What I18n-yaml files do you want to compare?'
|
9
|
-
@master = ask_for_file(true) # lang path app_name
|
10
|
-
@slave = ask_for_file(false)
|
11
|
-
raise 'Invalid Filepaths' unless File.exist?(@master[:path]) && File.exist?(@slave[:path])
|
12
|
-
|
13
|
-
paths = tmp_paths
|
4
|
+
def self.compare
|
5
|
+
@master, @slave, paths = init
|
14
6
|
|
15
7
|
prepare_for_edit(master: @master[:path], slave: @slave[:path])
|
16
|
-
|
17
8
|
prepare_paths([paths[:master], paths[:slave]])
|
18
9
|
|
19
10
|
master_file = YAML.load_file(paths[:master])
|
@@ -22,9 +13,7 @@ module LostInTranslation
|
|
22
13
|
count = diff(master_file[@master[:lang]], slave_file[@slave[:lang]], @master[:lang],
|
23
14
|
@slave[:lang], [@slave[:lang]], [], mode: 'count')
|
24
15
|
|
25
|
-
unless ask_for_permission(@master[:lang], @slave[:lang], @master[:app_name], count)
|
26
|
-
abort('Well, in that case, forget it!')
|
27
|
-
end
|
16
|
+
raise Breakup unless ask_for_permission(@master[:lang], @slave[:lang], @master[:app_name], count)
|
28
17
|
|
29
18
|
new_strings_array = diff(master_file[@master[:lang]], slave_file[@slave[:lang]], @master[:lang],
|
30
19
|
@slave[:lang], [@slave[:lang]], [], diff_count: count, mode: 'replace')
|
@@ -34,20 +23,13 @@ module LostInTranslation
|
|
34
23
|
merge_hash(result, slave_file)
|
35
24
|
end
|
36
25
|
|
37
|
-
sorted = false
|
38
|
-
|
39
|
-
if ask_for_sorting(@master[:lang], @master[:app_name])
|
40
|
-
master_file = sort_hash(master_file)
|
41
|
-
File.open(paths[:master], 'w') { |file| file.write(master_file.to_yaml(line_width: -1)) }
|
42
|
-
sorted = true
|
43
|
-
end
|
44
|
-
slave_file = sort_hash(slave_file) if ask_for_sorting(@slave[:lang], @slave[:app_name])
|
45
26
|
File.open(paths[:slave], 'w') { |file| file.write(slave_file.to_yaml(line_width: -1)) }
|
46
|
-
|
47
|
-
postpare_paths([paths[:master], paths[:slave]])
|
48
|
-
|
49
|
-
FileUtils.cp(paths[:master], @master[:path]) if sorted
|
27
|
+
postpare_paths([paths[:slave]])
|
50
28
|
FileUtils.cp(paths[:slave], @slave[:path])
|
29
|
+
|
51
30
|
reset_tmp_files
|
31
|
+
|
32
|
+
log 'Done'
|
33
|
+
log
|
52
34
|
end
|
53
35
|
end
|
data/lib/tasks/count.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LostInTranslation
|
4
|
+
def self.count
|
5
|
+
@master, @slave, paths = init
|
6
|
+
|
7
|
+
master_file = YAML.load_file(paths[:master])
|
8
|
+
slave_file = YAML.load_file(paths[:slave])
|
9
|
+
|
10
|
+
count = diff(master_file[@master[:lang]], slave_file[@slave[:lang]], @master[:lang], @slave[:lang],
|
11
|
+
[@slave[:lang]], [], mode: 'count')
|
12
|
+
|
13
|
+
count2 = diff(slave_file[@slave[:lang]], master_file[@master[:lang]], @slave[:lang], @master[:lang],
|
14
|
+
[@master[:lang]], [], mode: 'count')
|
15
|
+
|
16
|
+
log
|
17
|
+
log 'Differences between Locales'
|
18
|
+
log "#{@master[:filename]}.yml => #{@slave[:filename]}.yml = #{count}"
|
19
|
+
log "#{@slave[:filename]}.yml => #{@master[:filename]}.yml = #{count2}"
|
20
|
+
log
|
21
|
+
end
|
22
|
+
end
|
@@ -1,20 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
3
|
module LostInTranslation
|
5
|
-
def self.
|
6
|
-
|
7
|
-
log
|
8
|
-
log 'What I18n-yaml files do you want to compare?'
|
9
|
-
log '!!! WARNING!!! This deletes the differences!!! Make a BACKUP!!! !!!'
|
10
|
-
@master = ask_for_file(true) # lang path app_name
|
11
|
-
@slave = ask_for_file(false)
|
12
|
-
paths = tmp_paths
|
13
|
-
|
14
|
-
raise 'Invalid Filepaths' unless File.exist?(@master[:path]) && File.exist?(@slave[:path])
|
4
|
+
def self.delete_missing
|
5
|
+
@master, @slave, paths = init
|
15
6
|
|
16
7
|
prepare_for_edit(master: @master[:path], slave: @slave[:path])
|
17
|
-
|
18
8
|
prepare_paths([paths[:master], paths[:slave]])
|
19
9
|
|
20
10
|
master_file = YAML.load_file(paths[:master])
|
@@ -31,8 +21,9 @@ module LostInTranslation
|
|
31
21
|
end
|
32
22
|
|
33
23
|
File.open(@master[:path], 'w') { |file| file.write(master_file.to_yaml) }
|
34
|
-
|
35
24
|
postpare_paths([@master[:path], @slave[:path]])
|
36
25
|
reset_tmp_files
|
26
|
+
log 'Done'
|
27
|
+
log
|
37
28
|
end
|
38
29
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LostInTranslation
|
4
|
+
def self.compare
|
5
|
+
@master, @slave, paths = init
|
6
|
+
|
7
|
+
prepare_for_edit(master: @master[:path], slave: @slave[:path])
|
8
|
+
prepare_paths([paths[:master], paths[:slave]])
|
9
|
+
|
10
|
+
master_file = YAML.load_file(paths[:master])
|
11
|
+
slave_file = YAML.load_file(paths[:slave])
|
12
|
+
|
13
|
+
count = diff(master_file[@master[:lang]], slave_file[@slave[:lang]], @master[:lang],
|
14
|
+
@slave[:lang], [@slave[:lang]], [], mode: 'count')
|
15
|
+
|
16
|
+
raise Breakup unless ask_for_permission(@master[:lang], @slave[:lang], @master[:app_name], count)
|
17
|
+
|
18
|
+
new_strings_array = diff(master_file[@master[:lang]], slave_file[@slave[:lang]], @master[:lang],
|
19
|
+
@slave[:lang], [@slave[:lang]], [], diff_count: count, mode: 'replace')
|
20
|
+
|
21
|
+
new_strings_array.each do |string|
|
22
|
+
result = string_to_hash(string)
|
23
|
+
merge_hash(result, slave_file)
|
24
|
+
end
|
25
|
+
|
26
|
+
File.open(paths[:slave], 'w') { |file| file.write(slave_file.to_yaml(line_width: -1)) }
|
27
|
+
postpare_paths([paths[:slave]])
|
28
|
+
FileUtils.cp(paths[:slave], @slave[:path])
|
29
|
+
|
30
|
+
reset_tmp_files
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LostInTranslation
|
4
|
+
def self.compare
|
5
|
+
@master, @slave, paths = init
|
6
|
+
|
7
|
+
prepare_for_edit(master: @master[:path], slave: @slave[:path])
|
8
|
+
prepare_paths([paths[:master], paths[:slave]])
|
9
|
+
|
10
|
+
master_file = YAML.load_file(paths[:master])
|
11
|
+
slave_file = YAML.load_file(paths[:slave])
|
12
|
+
|
13
|
+
count = diff(master_file[@master[:lang]], slave_file[@slave[:lang]], @master[:lang],
|
14
|
+
@slave[:lang], [@slave[:lang]], [], mode: 'count')
|
15
|
+
|
16
|
+
raise Breakup unless ask_for_permission(@master[:lang], @slave[:lang], @master[:app_name], count)
|
17
|
+
|
18
|
+
new_strings_array = diff(master_file[@master[:lang]], slave_file[@slave[:lang]], @master[:lang],
|
19
|
+
@slave[:lang], [@slave[:lang]], [], diff_count: count, mode: 'replace')
|
20
|
+
|
21
|
+
new_strings_array.each do |string|
|
22
|
+
result = string_to_hash(string)
|
23
|
+
merge_hash(result, slave_file)
|
24
|
+
end
|
25
|
+
|
26
|
+
File.open(paths[:slave], 'w') { |file| file.write(slave_file.to_yaml(line_width: -1)) }
|
27
|
+
postpare_paths([paths[:slave]])
|
28
|
+
FileUtils.cp(paths[:slave], @slave[:path])
|
29
|
+
|
30
|
+
reset_tmp_files
|
31
|
+
end
|
32
|
+
end
|
data/lib/tasks/joke.rb
ADDED
@@ -2,14 +2,7 @@
|
|
2
2
|
|
3
3
|
module LostInTranslation
|
4
4
|
def self.recent
|
5
|
-
|
6
|
-
log
|
7
|
-
log 'What I18n-yaml files do you want to compare?'
|
8
|
-
@master = ask_for_file(true) # lang path app_name
|
9
|
-
@slave = ask_for_file(false)
|
10
|
-
paths = tmp_paths
|
11
|
-
|
12
|
-
raise 'Invalid Filepaths' unless File.exist?(@master[:path]) && File.exist?(@slave[:path])
|
5
|
+
@master, @slave, paths = init
|
13
6
|
|
14
7
|
FileUtils.cp(@master[:path], paths[:copy])
|
15
8
|
`git checkout "#{@master[:path]}"`
|
@@ -26,31 +19,23 @@ module LostInTranslation
|
|
26
19
|
count = diff(master_copy_file[@master[:lang]], master_file[@master[:lang]], @master[:lang],
|
27
20
|
@slave[:lang], [@slave[:lang]], [], mode: 'count', slave_file: slave_file)
|
28
21
|
|
29
|
-
|
22
|
+
raise Breakup unless ask_for_permission(@master[:lang], @slave[:lang], @master[:app_name], count)
|
30
23
|
|
31
24
|
new_strings_array = diff(master_copy_file[@master[:lang]], master_file[@master[:lang]], @master[:lang],
|
32
|
-
@slave[:lang], [@slave[:lang]], [], mode: 'replace', diff_counter: 0, diff_count: count,
|
25
|
+
@slave[:lang], [@slave[:lang]], [], mode: 'replace', diff_counter: 0, diff_count: count,
|
26
|
+
slave_file: slave_file)
|
33
27
|
|
34
28
|
new_strings_array.each do |string|
|
35
29
|
result = string_to_hash(string)
|
36
30
|
merge_hash(result, slave_file)
|
37
31
|
end
|
38
32
|
|
39
|
-
sorted = false
|
40
|
-
|
41
|
-
if ask_for_sorting(@master[:lang], @master[:app_name])
|
42
|
-
master_file = sort_hash(master_file)
|
43
|
-
File.open(paths[:master], 'w') { |file| file.write(master_file.to_yaml(line_width: -1)) }
|
44
|
-
sorted = true
|
45
|
-
end
|
46
|
-
|
47
|
-
slave_file = sort_hash(slave_file) if ask_for_sorting(@slave[:lang], @slave[:app_name])
|
48
33
|
File.open(paths[:slave], 'w') { |file| file.write(slave_file.to_yaml(line_width: -1)) }
|
49
|
-
|
50
|
-
postpare_paths([paths[:master], paths[:slave]])
|
51
|
-
|
52
|
-
FileUtils.cp(paths[:master], @master[:path]) if sorted
|
34
|
+
postpare_paths([paths[:slave]])
|
53
35
|
FileUtils.cp(paths[:slave], @slave[:path])
|
36
|
+
|
54
37
|
reset_tmp_files
|
38
|
+
log 'Done'
|
39
|
+
log
|
55
40
|
end
|
56
41
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LostInTranslation
|
4
|
+
def self.sort_file
|
5
|
+
@master, @slave, paths = init(false)
|
6
|
+
|
7
|
+
prepare_for_edit(master: @master[:path], slave: @slave[:path])
|
8
|
+
prepare_paths([paths[:master]])
|
9
|
+
|
10
|
+
master_file = YAML.load_file(paths[:master])
|
11
|
+
|
12
|
+
if ask_for_sorting(@master[:lang], @master[:app_name])
|
13
|
+
master_file = sort_hash(master_file)
|
14
|
+
File.open(paths[:master], 'w') { |file| file.write(master_file.to_yaml(line_width: -1)) }
|
15
|
+
end
|
16
|
+
|
17
|
+
postpare_paths([paths[:master]])
|
18
|
+
|
19
|
+
FileUtils.cp(paths[:master], @master[:path])
|
20
|
+
|
21
|
+
reset_tmp_files
|
22
|
+
log 'Done'
|
23
|
+
log
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LostInTranslation
|
4
|
+
def self.split_file
|
5
|
+
@master, @slave, paths = init(false)
|
6
|
+
|
7
|
+
prepare_for_edit(master: @master[:path])
|
8
|
+
prepare_paths([paths[:master]])
|
9
|
+
|
10
|
+
master_file = YAML.load_file(paths[:master])[@master[:lang]]
|
11
|
+
|
12
|
+
count = master_file.select { |_k, v| v.is_a?(Hash) }.size
|
13
|
+
new_hash = {}
|
14
|
+
|
15
|
+
if ask_for_split(@master[:lang], count)
|
16
|
+
master_file.each_pair do |key, value|
|
17
|
+
next unless value.is_a?(Hash)
|
18
|
+
new_hash[@master[:lang]] = { key => value }
|
19
|
+
File.open(paths[:slave], 'w') { |file| file.write(new_hash.to_yaml(line_width: -1)) }
|
20
|
+
postpare_paths([paths[:slave]])
|
21
|
+
root_path = @master[:path].split('/').reverse.drop(1).reverse.join('/')
|
22
|
+
filename = @master[:path].split('/').last
|
23
|
+
FileUtils.cp(paths[:slave], "#{root_path}/#{key}.#{filename}")
|
24
|
+
master_file.delete(key)
|
25
|
+
end
|
26
|
+
|
27
|
+
new_hash[@master[:lang]] = master_file
|
28
|
+
File.open(paths[:master], 'w') { |file| file.write(new_hash.to_yaml(line_width: -1)) }
|
29
|
+
postpare_paths([paths[:master]])
|
30
|
+
FileUtils.cp(paths[:master], @master[:path])
|
31
|
+
end
|
32
|
+
|
33
|
+
reset_tmp_files
|
34
|
+
log 'Done'
|
35
|
+
log
|
36
|
+
end
|
37
|
+
end
|
data/lib/tasks/start.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LostInTranslation
|
4
|
+
def self.start
|
5
|
+
tasks = [
|
6
|
+
{ text: 'Compare & Translate two I18n-Locale-Files', method: :compare },
|
7
|
+
{ text: 'Compare two I18n-Locale-Files and delete the differences', method: :delete_missing },
|
8
|
+
{ text: 'Count Differences of 2 I18n-Locale-Files', method: :count },
|
9
|
+
{ text: 'Sort an I18n-Locale-File Alphabetically & Recursive (ASC)', method: :sort_file },
|
10
|
+
{ text: 'Split an I18n-Locale-File into multiple namespaced Files (1. Level)', method: :split_file },
|
11
|
+
{ text: 'Tell me joke', method: :joke }
|
12
|
+
]
|
13
|
+
task = ask_for_task(tasks)
|
14
|
+
LostInTranslation.send(task[:method])
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'lost_in_translation'
|
2
|
+
|
3
|
+
namespace :lit do
|
4
|
+
desc 'Make the locale-yamls equal again(Interactive)'
|
5
|
+
task :compare do
|
6
|
+
LostInTranslation.compare
|
7
|
+
end
|
8
|
+
|
9
|
+
desc 'Just start and get lead through the process'
|
10
|
+
task :start do
|
11
|
+
LostInTranslation.start
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'Use Translator-Engine as a suggestion for translation'
|
15
|
+
task :half_automatic do
|
16
|
+
return 'to_be_done'
|
17
|
+
# LostInTranslation.half_automatic
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'Use Translator-Engine to automatically translate everything'
|
21
|
+
task :fully_automatic do
|
22
|
+
return 'to_be_done'
|
23
|
+
# LostInTranslation.fully_automatic
|
24
|
+
end
|
25
|
+
|
26
|
+
desc 'Split big files in many small ones'
|
27
|
+
task :split_file do
|
28
|
+
# return 'to_be_done'
|
29
|
+
LostInTranslation.split_file
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'Sort Locale-File recursively'
|
33
|
+
task :sort_file do
|
34
|
+
return 'to_be_done'
|
35
|
+
# LostInTranslation.sort_file
|
36
|
+
end
|
37
|
+
|
38
|
+
desc 'Cleaning out the Yaml-Closet'
|
39
|
+
task :delete_missing do
|
40
|
+
return 'to_be_done'
|
41
|
+
# LostInTranslation.delete_missing
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'Tranlate just your recently changed Strings(requires git)'
|
45
|
+
task :recent do
|
46
|
+
abort('Please use this feature inside a Rails-Application') unless defined? Rails
|
47
|
+
LostInTranslation.recent
|
48
|
+
end
|
49
|
+
end
|
data/lost_in_translation.gemspec
CHANGED
@@ -2,11 +2,10 @@
|
|
2
2
|
|
3
3
|
lib = File.expand_path('../lib', __FILE__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require 'lost_in_translation/version'
|
6
5
|
|
7
6
|
Gem::Specification.new do |spec|
|
8
7
|
spec.name = 'lost_in_translation'
|
9
|
-
spec.version =
|
8
|
+
spec.version = '0.2.17'
|
10
9
|
spec.authors = ['Datyv']
|
11
10
|
spec.email = ['yvesgoizet@gmail.com']
|
12
11
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lost_in_translation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Datyv
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -61,7 +61,6 @@ extra_rdoc_files: []
|
|
61
61
|
files:
|
62
62
|
- ".gitignore"
|
63
63
|
- ".rspec"
|
64
|
-
- ".rubocop.yml"
|
65
64
|
- ".travis.yml"
|
66
65
|
- CODE_OF_CONDUCT.md
|
67
66
|
- Gemfile
|
@@ -70,19 +69,23 @@ files:
|
|
70
69
|
- Rakefile
|
71
70
|
- bin/console
|
72
71
|
- bin/setup
|
72
|
+
- lib/lit/difference.rb
|
73
|
+
- lib/lit/file_functions.rb
|
74
|
+
- lib/lit/hash.rb
|
75
|
+
- lib/lit/railties.rb
|
76
|
+
- lib/lit/user_interface.rb
|
73
77
|
- lib/lost_in_translation.rb
|
74
|
-
- lib/
|
75
|
-
- lib/
|
76
|
-
- lib/
|
77
|
-
- lib/
|
78
|
-
- lib/
|
79
|
-
- lib/
|
80
|
-
- lib/
|
81
|
-
- lib/
|
82
|
-
- lib/
|
83
|
-
- lib/
|
84
|
-
- lib/
|
85
|
-
- lib/tasks/lit.rake
|
78
|
+
- lib/tasks/compare.rb
|
79
|
+
- lib/tasks/count.rb
|
80
|
+
- lib/tasks/delete_missing.rb
|
81
|
+
- lib/tasks/fully_automatic.rb
|
82
|
+
- lib/tasks/half_automatic.rb
|
83
|
+
- lib/tasks/joke.rb
|
84
|
+
- lib/tasks/recent.rb
|
85
|
+
- lib/tasks/sort_file.rb
|
86
|
+
- lib/tasks/split_file.rb
|
87
|
+
- lib/tasks/start.rb
|
88
|
+
- lib/tasks/tasks.rake
|
86
89
|
- lost_in_translation.gemspec
|
87
90
|
- tmp/tmp_master.yml
|
88
91
|
- tmp/tmp_master_copy.yml
|
data/.rubocop.yml
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
# This is the configuration used to check the rubocop source code.
|
2
|
-
|
3
|
-
|
4
|
-
AllCops:
|
5
|
-
TargetRubyVersion: 2.3
|
6
|
-
Exclude:
|
7
|
-
- 'vendor/**/*'
|
8
|
-
- 'spec/fixtures/**/*'
|
9
|
-
- 'db/functional_test_data.rb'
|
10
|
-
- 'db/schema.rb'
|
11
|
-
|
12
|
-
Lint/HandleExceptions:
|
13
|
-
Exclude:
|
14
|
-
- 'bin/rails'
|
15
|
-
- 'bin/rake'
|
16
|
-
- 'bin/rspec'
|
17
|
-
|
18
|
-
Style/Encoding:
|
19
|
-
Enabled: true
|
20
|
-
|
21
|
-
Style/NumericLiterals:
|
22
|
-
Enabled: false
|
23
|
-
|
24
|
-
Style/RescueModifier:
|
25
|
-
Enabled: false
|
26
|
-
|
27
|
-
Metrics/LineLength:
|
28
|
-
Max: 120
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module LostInTranslation
|
2
|
-
def self.full_automatic
|
3
|
-
if defined? Rails
|
4
|
-
lang2, lang1 = LostInTranslation.ask_for_languages
|
5
|
-
path1 = "#{Rails.root}/config/locales/#{lang1}.yml"
|
6
|
-
path2 = "#{Rails.root}/config/locales/#{lang2}.yml"
|
7
|
-
else
|
8
|
-
path2, path1 = LostInTranslation.ask_for_paths
|
9
|
-
|
10
|
-
lang1 = LostInTranslation.get_locale(path1)
|
11
|
-
lang2 = LostInTranslation.get_locale(path2)
|
12
|
-
end
|
13
|
-
|
14
|
-
abort('NOPE') unless File.exist?(path1) && File.exist?(path2)
|
15
|
-
|
16
|
-
first = YAML.load_file(path1)
|
17
|
-
second = YAML.load_file(path2)
|
18
|
-
|
19
|
-
new_strings_array = LostInTranslation.clean(first[lang1], second[lang2], [lang2])
|
20
|
-
|
21
|
-
first = {}
|
22
|
-
new_strings_array.each do |string|
|
23
|
-
string = string.split('---').map { |x| x == lang2 ? lang1 : x }.join('---')
|
24
|
-
result = LostInTranslation.string_to_hash(string)
|
25
|
-
LostInTranslation.merge_hash(result, first)
|
26
|
-
end
|
27
|
-
|
28
|
-
File.open(path1, 'w') { |file| file.write(first.to_yaml) }
|
29
|
-
end
|
30
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
#
|
4
|
-
module LostInTranslation
|
5
|
-
def self.half_automatic
|
6
|
-
if defined? Rails
|
7
|
-
lang2, lang1 = LostInTranslation.ask_for_languages
|
8
|
-
path1 = "#{Rails.root}/config/locales/#{lang1}.yml"
|
9
|
-
path2 = "#{Rails.root}/config/locales/#{lang2}.yml"
|
10
|
-
else
|
11
|
-
path2, path1 = LostInTranslation.ask_for_paths
|
12
|
-
|
13
|
-
lang1 = LostInTranslation.get_locale(path1)
|
14
|
-
lang2 = LostInTranslation.get_locale(path2)
|
15
|
-
end
|
16
|
-
|
17
|
-
abort('NOPE') unless File.exist?(path1) && File.exist?(path2)
|
18
|
-
|
19
|
-
first = YAML.load_file(path1)
|
20
|
-
second = YAML.load_file(path2)
|
21
|
-
|
22
|
-
new_strings_array = LostInTranslation.clean(first[lang1], second[lang2], [lang2])
|
23
|
-
|
24
|
-
first = {}
|
25
|
-
new_strings_array.each do |string|
|
26
|
-
string = string.split('---').map { |x| x == lang2 ? lang1 : x }.join('---')
|
27
|
-
result = LostInTranslation.string_to_hash(string)
|
28
|
-
LostInTranslation.merge_hash(result, first)
|
29
|
-
end
|
30
|
-
|
31
|
-
File.open(path1, 'w') { |file| file.write(first.to_yaml) }
|
32
|
-
end
|
33
|
-
end
|
data/lib/tasks/lit.rake
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'yaml'
|
4
|
-
require 'lost_in_translation'
|
5
|
-
require 'fileutils'
|
6
|
-
|
7
|
-
namespace :lit do
|
8
|
-
desc 'Make the locale-yamls equal again(Interactive)'
|
9
|
-
task :interactive do
|
10
|
-
LostInTranslation.interactive
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
namespace :lit do
|
15
|
-
desc 'Use Bing-Translator as a suggestion for translation'
|
16
|
-
task :half_automatic do
|
17
|
-
return 'to_be_done'
|
18
|
-
# LostInTranslation.half_automatic
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
namespace :lit do
|
23
|
-
desc 'Use Bing-Translator to automatically translate everything'
|
24
|
-
task :fully_automatic do
|
25
|
-
return 'to_be_done'
|
26
|
-
# LostInTranslation.full_automatic
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
namespace :lit do
|
31
|
-
desc 'Cleaning out the Yaml-Closet'
|
32
|
-
task :cleanup do
|
33
|
-
return 'to_be_done'
|
34
|
-
# LostInTranslation.cleanup
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
namespace :lit do
|
39
|
-
desc 'Tranlate just your recently changed Strings(requires git)'
|
40
|
-
task :recent do
|
41
|
-
abort('Please use this feature inside a Rails-Application') unless defined? Rails
|
42
|
-
LostInTranslation.recent
|
43
|
-
end
|
44
|
-
end
|