lost_in_translation 0.2.1 → 0.2.2
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 +4 -4
- data/README.md +3 -3
- data/lib/lost_in_translation.rb +1 -1
- data/lib/lost_in_translation/version.rb +1 -1
- data/lib/lost_in_translation/z_cleanup.rb +7 -7
- data/lib/lost_in_translation/z_full_automatic.rb +7 -7
- data/lib/lost_in_translation/z_half_automatic.rb +7 -7
- data/lib/lost_in_translation/z_interactive.rb +11 -11
- data/lib/lost_in_translation/z_recent.rb +7 -7
- data/lib/tasks/lit.rake +5 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b5ad5b54d21c5230363ffd5484b7ea677ab628e
|
4
|
+
data.tar.gz: ce901a81a874616cb4c3dd91f209592861afaf76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db2cff3026ff8b913ec0149c92b735a17717f9ceb3868a1e15a7519d006ffff8ec277bd8d57adef022b989c29a6b3c8885f29385f2045a335e4d24b54f371683
|
7
|
+
data.tar.gz: 5a086bf90a4b44a4f928fb25ca9f4634e27010c237a1cf2aabdc1597fefb3450475f6f7695eac4b260ded0ed7678c521071c14f14dcd795762fdcb5307500673
|
data/README.md
CHANGED
@@ -65,11 +65,11 @@ In this case you can use the Rails-Console and the Class -LostInTranslation-.
|
|
65
65
|
rails c
|
66
66
|
```
|
67
67
|
```
|
68
|
-
|
68
|
+
LostInTranslationMain.interactive
|
69
69
|
or
|
70
|
-
|
70
|
+
LostInTranslationMain.recent
|
71
71
|
or
|
72
|
-
|
72
|
+
LostInTranslationMain.cleanup
|
73
73
|
```
|
74
74
|
|
75
75
|
#### Yet to come
|
data/lib/lost_in_translation.rb
CHANGED
@@ -2,15 +2,15 @@ module LostInTranslation
|
|
2
2
|
def cleanup
|
3
3
|
if defined? Rails
|
4
4
|
app_name = Rails.application.class.parent_name
|
5
|
-
lang_2, lang_1 =
|
5
|
+
lang_2, lang_1 = LostInTranslationMain.ask_for_languages
|
6
6
|
path_1 = "#{Rails.root}/config/locales/#{lang_1}.yml"
|
7
7
|
path_2 = "#{Rails.root}/config/locales/#{lang_2}.yml"
|
8
8
|
else
|
9
9
|
app_name = nil
|
10
|
-
path_2, path_1 =
|
10
|
+
path_2, path_1 = LostInTranslationMain.ask_for_paths
|
11
11
|
|
12
|
-
lang_1 =
|
13
|
-
lang_2 =
|
12
|
+
lang_1 = LostInTranslationMain.get_locale(path_1)
|
13
|
+
lang_2 = LostInTranslationMain.get_locale(path_2)
|
14
14
|
end
|
15
15
|
|
16
16
|
abort('NOPE') unless File.exist?(path_1) && File.exist?(path_2)
|
@@ -20,13 +20,13 @@ module LostInTranslation
|
|
20
20
|
first = YAML.load_file(path_1)
|
21
21
|
second = YAML.load_file(path_2)
|
22
22
|
|
23
|
-
new_strings_array =
|
23
|
+
new_strings_array = LostInTranslationMain.clean(first[lang_1], second[lang_2], [lang_2])
|
24
24
|
|
25
25
|
first = {}
|
26
26
|
new_strings_array.each do |string|
|
27
27
|
string = string.split('---').map { |x| x == lang_2 ? x = lang_1 : x }.join('---')
|
28
|
-
result =
|
29
|
-
|
28
|
+
result = LostInTranslationMain.string_to_hash(string)
|
29
|
+
LostInTranslationMain.merge_hash(result, first)
|
30
30
|
end
|
31
31
|
|
32
32
|
File.open(path_1, 'w') { |file| file.write(first.to_yaml) }
|
@@ -2,15 +2,15 @@ module LostInTranslation
|
|
2
2
|
def full_automatic
|
3
3
|
if defined? Rails
|
4
4
|
app_name = Rails.application.class.parent_name
|
5
|
-
lang_2, lang_1 =
|
5
|
+
lang_2, lang_1 = LostInTranslationMain.ask_for_languages
|
6
6
|
path_1 = "#{Rails.root}/config/locales/#{lang_1}.yml"
|
7
7
|
path_2 = "#{Rails.root}/config/locales/#{lang_2}.yml"
|
8
8
|
else
|
9
9
|
app_name = nil
|
10
|
-
path_2, path_1 =
|
10
|
+
path_2, path_1 = LostInTranslationMain.ask_for_paths
|
11
11
|
|
12
|
-
lang_1 =
|
13
|
-
lang_2 =
|
12
|
+
lang_1 = LostInTranslationMain.get_locale(path_1)
|
13
|
+
lang_2 = LostInTranslationMain.get_locale(path_2)
|
14
14
|
end
|
15
15
|
|
16
16
|
abort('NOPE') unless File.exist?(path_1) && File.exist?(path_2)
|
@@ -18,13 +18,13 @@ module LostInTranslation
|
|
18
18
|
first = YAML.load_file(path_1)
|
19
19
|
second = YAML.load_file(path_2)
|
20
20
|
|
21
|
-
new_strings_array =
|
21
|
+
new_strings_array = LostInTranslationMain.clean(first[lang_1], second[lang_2], [lang_2])
|
22
22
|
|
23
23
|
first = {}
|
24
24
|
new_strings_array.each do |string|
|
25
25
|
string = string.split('---').map { |x| x == lang_2 ? x = lang_1 : x }.join('---')
|
26
|
-
result =
|
27
|
-
|
26
|
+
result = LostInTranslationMain.string_to_hash(string)
|
27
|
+
LostInTranslationMain.merge_hash(result, first)
|
28
28
|
end
|
29
29
|
|
30
30
|
File.open(path_1, 'w') { |file| file.write(first.to_yaml) }
|
@@ -2,15 +2,15 @@ module LostInTranslation
|
|
2
2
|
def half_automatic
|
3
3
|
if defined? Rails
|
4
4
|
app_name = Rails.application.class.parent_name
|
5
|
-
lang_2, lang_1 =
|
5
|
+
lang_2, lang_1 = LostInTranslationMain.ask_for_languages
|
6
6
|
path_1 = "#{Rails.root}/config/locales/#{lang_1}.yml"
|
7
7
|
path_2 = "#{Rails.root}/config/locales/#{lang_2}.yml"
|
8
8
|
else
|
9
9
|
app_name = nil
|
10
|
-
path_2, path_1 =
|
10
|
+
path_2, path_1 = LostInTranslationMain.ask_for_paths
|
11
11
|
|
12
|
-
lang_1 =
|
13
|
-
lang_2 =
|
12
|
+
lang_1 = LostInTranslationMain.get_locale(path_1)
|
13
|
+
lang_2 = LostInTranslationMain.get_locale(path_2)
|
14
14
|
end
|
15
15
|
|
16
16
|
abort('NOPE') unless File.exist?(path_1) && File.exist?(path_2)
|
@@ -18,13 +18,13 @@ module LostInTranslation
|
|
18
18
|
first = YAML.load_file(path_1)
|
19
19
|
second = YAML.load_file(path_2)
|
20
20
|
|
21
|
-
new_strings_array =
|
21
|
+
new_strings_array = LostInTranslationMain.clean(first[lang_1], second[lang_2], [lang_2])
|
22
22
|
|
23
23
|
first = {}
|
24
24
|
new_strings_array.each do |string|
|
25
25
|
string = string.split('---').map { |x| x == lang_2 ? x = lang_1 : x }.join('---')
|
26
|
-
result =
|
27
|
-
|
26
|
+
result = LostInTranslationMain.string_to_hash(string)
|
27
|
+
LostInTranslationMain.merge_hash(result, first)
|
28
28
|
end
|
29
29
|
|
30
30
|
File.open(path_1, 'w') { |file| file.write(first.to_yaml) }
|
@@ -2,19 +2,19 @@ module LostInTranslation
|
|
2
2
|
def interactive
|
3
3
|
if defined? Rails
|
4
4
|
app_name = Rails.application.class.parent_name
|
5
|
-
lang_1, lang_2 =
|
5
|
+
lang_1, lang_2 = LostInTranslationMain.ask_for_languages
|
6
6
|
path_1 = "#{Rails.root}/config/locales/#{lang_1}.yml"
|
7
7
|
path_2 = "#{Rails.root}/config/locales/#{lang_2}.yml"
|
8
8
|
else
|
9
9
|
app_name = nil
|
10
|
-
path_1, path_2 =
|
10
|
+
path_1, path_2 = LostInTranslationMain.ask_for_paths
|
11
11
|
|
12
|
-
lang_1 =
|
13
|
-
lang_2 =
|
12
|
+
lang_1 = LostInTranslationMain.get_locale(path_1)
|
13
|
+
lang_2 = LostInTranslationMain.get_locale(path_2)
|
14
14
|
end
|
15
15
|
|
16
16
|
abort('NOPE') unless File.exist?(path_1) && File.exist?(path_2)
|
17
|
-
abort('Well, in that case, forget it!') unless
|
17
|
+
abort('Well, in that case, forget it!') unless LostInTranslationMain.ask_for_permission(lang_1,lang_2,app_name)
|
18
18
|
|
19
19
|
prepare_paths(path_1, path_2, true)
|
20
20
|
prepare_paths(path_1, path_2, false)
|
@@ -22,19 +22,19 @@ module LostInTranslation
|
|
22
22
|
first = YAML.load_file(path_1)
|
23
23
|
second = YAML.load_file(path_2)
|
24
24
|
|
25
|
-
new_strings_array =
|
25
|
+
new_strings_array = LostInTranslationMain.diff(first[lang_1], second[lang_2], lang_1, lang_2, [lang_2])
|
26
26
|
|
27
27
|
new_strings_array.each do |string|
|
28
|
-
result =
|
29
|
-
|
28
|
+
result = LostInTranslationMain.string_to_hash(string)
|
29
|
+
LostInTranslationMain.merge_hash(result, second)
|
30
30
|
end
|
31
31
|
|
32
|
-
if
|
33
|
-
first =
|
32
|
+
if LostInTranslationMain.ask_for_sorting(lang_1, app_name)
|
33
|
+
first = LostInTranslationMain.sort_hash(first)
|
34
34
|
File.open(path_1, 'w') { |file| file.write(first.to_yaml(line_width: -1)) }
|
35
35
|
end
|
36
36
|
|
37
|
-
second =
|
37
|
+
second = LostInTranslationMain.sort_hash(second) if LostInTranslationMain.ask_for_sorting(lang_2, app_name)
|
38
38
|
File.open(path_2, 'w') { |file| file.write(second.to_yaml(line_width: -1)) }
|
39
39
|
|
40
40
|
prepare_paths(path_1, path_2, true)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module LostInTranslation
|
2
2
|
def recent
|
3
3
|
app_name = Rails.application.class.parent_name
|
4
|
-
lang_1, lang_2 =
|
4
|
+
lang_1, lang_2 = LostInTranslationMain.ask_for_languages
|
5
5
|
path_1 = "#{Rails.root}/config/locales/#{lang_1}.yml"
|
6
6
|
copy_path_1 = "#{Rails.root}/config/locales/#{lang_1}_copy.yml"
|
7
7
|
path_2 = "#{Rails.root}/config/locales/#{lang_2}.yml"
|
@@ -16,20 +16,20 @@ module LostInTranslation
|
|
16
16
|
first = YAML.load_file(path_1)
|
17
17
|
first_copy = YAML.load_file(copy_path_1)
|
18
18
|
second = YAML.load_file(path_2)
|
19
|
-
new_strings_array =
|
19
|
+
new_strings_array = LostInTranslationMain.diff(first_copy[lang_1], first[lang_1], lang_1, lang_2, [lang_1])
|
20
20
|
|
21
21
|
new_strings_array.each do |string|
|
22
22
|
string = string.split('---').map { |x| x == lang_1 ? x = lang_2 : x }.join('---')
|
23
|
-
result =
|
24
|
-
|
23
|
+
result = LostInTranslationMain.string_to_hash(string)
|
24
|
+
LostInTranslationMain.merge_hash(result, second)
|
25
25
|
end
|
26
26
|
|
27
|
-
if
|
28
|
-
first_copy =
|
27
|
+
if LostInTranslationMain.ask_for_sorting(lang_1, app_name)
|
28
|
+
first_copy = LostInTranslationMain.sort_hash(first_copy)
|
29
29
|
File.open(path_1, 'w') { |file| file.write(first_copy.to_yaml) }
|
30
30
|
end
|
31
31
|
|
32
|
-
second =
|
32
|
+
second = LostInTranslationMain.sort_hash(second) if LostInTranslationMain.ask_for_sorting(lang_2, app_name)
|
33
33
|
File.open(path_2, 'w') { |file| file.write(second.to_yaml) }
|
34
34
|
prepare_paths(path_1, path_2, true)
|
35
35
|
|
data/lib/tasks/lit.rake
CHANGED
@@ -5,7 +5,7 @@ require 'fileutils'
|
|
5
5
|
namespace :lit do
|
6
6
|
desc "Make the locale-yamls equal again(Interactive)"
|
7
7
|
task :interactive do
|
8
|
-
|
8
|
+
LostInTranslationMain.interactive
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
@@ -13,7 +13,7 @@ namespace :lit do
|
|
13
13
|
desc "Use Bing-Translator as a suggestion for translation"
|
14
14
|
task :half_automatic do
|
15
15
|
return 'to_be_done'
|
16
|
-
|
16
|
+
LostInTranslationMain.half_automatic
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -21,14 +21,14 @@ namespace :lit do
|
|
21
21
|
desc "Use Bing-Translator to automatically translate everything"
|
22
22
|
task :fully_automatic do
|
23
23
|
return 'to_be_done'
|
24
|
-
|
24
|
+
LostInTranslationMain.full_automatic
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
namespace :lit do
|
29
29
|
desc "Cleaning out the Yaml-Closet"
|
30
30
|
task :cleanup do
|
31
|
-
|
31
|
+
LostInTranslationMain.cleanup
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -36,6 +36,6 @@ namespace :lit do
|
|
36
36
|
desc "Tranlate just your recently changed Strings(requires git)"
|
37
37
|
task :recent do
|
38
38
|
abort('Please use this feature inside a Rails-Application') unless defined? Rails
|
39
|
-
|
39
|
+
LostInTranslationMain.recent
|
40
40
|
end
|
41
41
|
end
|