lost_in_translation 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -5
- data/Rakefile +1 -1
- data/lib/lost_in_translation.rb +1 -1
- data/lib/lost_in_translation/file_functions.rb +2 -0
- data/lib/lost_in_translation/version.rb +1 -1
- data/lib/lost_in_translation/z_cleanup.rb +9 -9
- 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 +9 -9
- data/lib/tasks/{translate.rake → lit.rake} +11 -11
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf6836b41a6cef14f6f3b0eb18dd959d9679cd84
|
4
|
+
data.tar.gz: 568b3b0a478257fb6b6ee8155463771f8dcee55b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b56b7926b71d727ba4f170d2146bb7a8b63035eb53df1f0900e8cb4e9e40386a7fb6a7b0360bf37d3f88d613e6818d8a00b29e33f8d1a76b4ce46f7ebf3ce6bc
|
7
|
+
data.tar.gz: faed2e14fc2d1d6deabd08724a1249e5b5a4ad67a2883bbf96fdf55850391ec23c0b0a6483b14a187e79f1e8aebe9741a6e0c5332e951de3e24daf3aa4a07988
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# LostInTranslation
|
2
2
|
|
3
|
-
This gem provides you three tasks to translate your
|
3
|
+
This gem provides you three tasks to translate your locale yamls!
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -21,7 +21,7 @@ Or install it yourself as:
|
|
21
21
|
## Usage
|
22
22
|
There are three tasks you can execute.
|
23
23
|
|
24
|
-
### ATTENTION: Use at your own risk! Back
|
24
|
+
### ATTENTION: Use at your own risk! Back your shit up, before using this!
|
25
25
|
Each will ask you for the file
|
26
26
|
If this gem is installed inside a Rails-Application you just have to written
|
27
27
|
e.g.:
|
@@ -36,7 +36,7 @@ One will be the slave-file (this one will be changed)
|
|
36
36
|
|
37
37
|
#### Script 1: Interactive
|
38
38
|
```bash
|
39
|
-
rake
|
39
|
+
rake lit:interactive
|
40
40
|
```
|
41
41
|
This script will ask you for the missing value.
|
42
42
|
It will find every difference and will ask you to fill every hole... yeah.
|
@@ -44,7 +44,7 @@ After everything is filled out it will merge the data back into your File.
|
|
44
44
|
|
45
45
|
#### Script 2: Recent
|
46
46
|
```bash
|
47
|
-
rake
|
47
|
+
rake lit:recent
|
48
48
|
```
|
49
49
|
REQUIRED: Connection to Git
|
50
50
|
This script will ask you for the missing value.
|
@@ -53,11 +53,28 @@ After everything is filled out it will merge the data back into your File.
|
|
53
53
|
|
54
54
|
#### Script 3: Cleanup (Deletes something!)
|
55
55
|
```bash
|
56
|
-
rake
|
56
|
+
rake lit:cleanup
|
57
57
|
```
|
58
58
|
This script will find every key/value inside your slave-file that isn´t present in your master-file.
|
59
59
|
And it will be deleted!!!!
|
60
60
|
|
61
|
+
#### Sometimes the Rake tasks aren't working
|
62
|
+
In this case you can use the Rails-Console and the Class -LostInTranslation-.
|
63
|
+
|
64
|
+
```bash
|
65
|
+
rails c
|
66
|
+
```
|
67
|
+
```
|
68
|
+
LostInTranslation.interactive
|
69
|
+
or
|
70
|
+
LostInTranslation.recent
|
71
|
+
or
|
72
|
+
LostInTranslation.cleanup
|
73
|
+
```
|
74
|
+
|
75
|
+
#### Yet to come
|
76
|
+
I am planning on an integration of Translation APIs.
|
77
|
+
|
61
78
|
## Contributing
|
62
79
|
|
63
80
|
Bug reports and pull requests are welcome on GitHub at https://github.com/datyv/lost_in_translation. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
data/Rakefile
CHANGED
data/lib/lost_in_translation.rb
CHANGED
@@ -2,35 +2,35 @@ 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 = LostInTranslation.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 = LostInTranslation.ask_for_paths
|
11
11
|
|
12
|
-
lang_1 =
|
13
|
-
lang_2 =
|
12
|
+
lang_1 = LostInTranslation.get_locale(path_1)
|
13
|
+
lang_2 = LostInTranslation.get_locale(path_2)
|
14
14
|
end
|
15
15
|
|
16
16
|
abort('NOPE') unless File.exist?(path_1) && File.exist?(path_2)
|
17
17
|
|
18
|
-
|
18
|
+
prepare_paths(path_1, path_2, false)
|
19
19
|
|
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 = LostInTranslation.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 = LostInTranslation.string_to_hash(string)
|
29
|
+
LostInTranslation.merge_hash(result, first)
|
30
30
|
end
|
31
31
|
|
32
32
|
File.open(path_1, 'w') { |file| file.write(first.to_yaml) }
|
33
33
|
|
34
|
-
|
34
|
+
prepare_paths(path_1, path_2, true)
|
35
35
|
end
|
36
36
|
end
|
@@ -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 = LostInTranslation.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 = LostInTranslation.ask_for_paths
|
11
11
|
|
12
|
-
lang_1 =
|
13
|
-
lang_2 =
|
12
|
+
lang_1 = LostInTranslation.get_locale(path_1)
|
13
|
+
lang_2 = LostInTranslation.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 = LostInTranslation.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 = LostInTranslation.string_to_hash(string)
|
27
|
+
LostInTranslation.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 = LostInTranslation.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 = LostInTranslation.ask_for_paths
|
11
11
|
|
12
|
-
lang_1 =
|
13
|
-
lang_2 =
|
12
|
+
lang_1 = LostInTranslation.get_locale(path_1)
|
13
|
+
lang_2 = LostInTranslation.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 = LostInTranslation.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 = LostInTranslation.string_to_hash(string)
|
27
|
+
LostInTranslation.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 = LostInTranslation.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 = LostInTranslation.ask_for_paths
|
11
11
|
|
12
|
-
lang_1 =
|
13
|
-
lang_2 =
|
12
|
+
lang_1 = LostInTranslation.get_locale(path_1)
|
13
|
+
lang_2 = LostInTranslation.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 LostInTranslation.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 = LostInTranslation.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 = LostInTranslation.string_to_hash(string)
|
29
|
+
LostInTranslation.merge_hash(result, second)
|
30
30
|
end
|
31
31
|
|
32
|
-
if
|
33
|
-
first =
|
32
|
+
if LostInTranslation.ask_for_sorting(lang_1, app_name)
|
33
|
+
first = LostInTranslation.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 = LostInTranslation.sort_hash(second) if LostInTranslation.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 = LostInTranslation.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"
|
@@ -11,27 +11,27 @@ module LostInTranslation
|
|
11
11
|
FileUtils.cp(path_1, copy_path_1)
|
12
12
|
`git checkout "#{path_1}"`
|
13
13
|
|
14
|
-
|
14
|
+
prepare_paths(path_1, copy_path_1, false)
|
15
15
|
|
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 = LostInTranslation.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 = LostInTranslation.string_to_hash(string)
|
24
|
+
LostInTranslation.merge_hash(result, second)
|
25
25
|
end
|
26
26
|
|
27
|
-
if
|
28
|
-
first_copy =
|
27
|
+
if LostInTranslation.ask_for_sorting(lang_1, app_name)
|
28
|
+
first_copy = LostInTranslation.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 = LostInTranslation.sort_hash(second) if LostInTranslation.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
|
|
36
36
|
FileUtils.rm(copy_path_1)
|
37
37
|
end
|
@@ -2,40 +2,40 @@ require 'yaml'
|
|
2
2
|
require 'lost_in_translation'
|
3
3
|
require 'fileutils'
|
4
4
|
|
5
|
-
namespace :
|
5
|
+
namespace :lit do
|
6
6
|
desc "Make the locale-yamls equal again(Interactive)"
|
7
7
|
task :interactive do
|
8
|
-
|
8
|
+
LostInTranslation.interactive
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
namespace :
|
12
|
+
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
|
+
LostInTranslation.half_automatic
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
namespace :
|
20
|
+
namespace :lit do
|
21
21
|
desc "Use Bing-Translator to automatically translate everything"
|
22
|
-
task :
|
22
|
+
task :fully_automatic do
|
23
23
|
return 'to_be_done'
|
24
|
-
|
24
|
+
LostInTranslation.full_automatic
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
namespace :
|
28
|
+
namespace :lit do
|
29
29
|
desc "Cleaning out the Yaml-Closet"
|
30
30
|
task :cleanup do
|
31
|
-
|
31
|
+
LostInTranslation.cleanup
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
namespace :
|
35
|
+
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
|
+
LostInTranslation.recent
|
40
40
|
end
|
41
41
|
end
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Datyv
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -81,7 +81,7 @@ files:
|
|
81
81
|
- lib/lost_in_translation/z_half_automatic.rb
|
82
82
|
- lib/lost_in_translation/z_interactive.rb
|
83
83
|
- lib/lost_in_translation/z_recent.rb
|
84
|
-
- lib/tasks/
|
84
|
+
- lib/tasks/lit.rake
|
85
85
|
- lost_in_translation.gemspec
|
86
86
|
homepage: https://github.com/Datyv/lost_in_translation
|
87
87
|
licenses:
|