lost_in_translation 0.0.1 → 0.1.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.
- checksums.yaml +4 -4
- data/lib/lost_in_translation/hash.rb +3 -16
- data/lib/lost_in_translation/version.rb +1 -1
- data/lib/lost_in_translation/{cleanup.rb → z_cleanup.rb} +0 -0
- data/lib/lost_in_translation/z_full_automatic.rb +32 -0
- data/lib/lost_in_translation/z_half_automatic.rb +32 -0
- data/lib/lost_in_translation/{interactive.rb → z_interactive.rb} +0 -0
- data/lib/lost_in_translation/{recent.rb → z_recent.rb} +0 -0
- data/lib/lost_in_translation.rb +5 -3
- data/lib/tasks/translate.rake +4 -2
- data/lost_in_translation.gemspec +3 -3
- metadata +11 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3bad89e7e9d374aea300f0e82e7dd12150a88c1
|
4
|
+
data.tar.gz: b398954b97e65e4d97c281f8c9c1b63a2c41ab02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7ea20ba1c81836f792c9cf62e40141fd633e5e3346b2302393eb7f9c95e765fc38f254ffec11a425481f9e45432414bc34fbff612b64c760f3e2eb473d8a0de
|
7
|
+
data.tar.gz: f53813c261b74a4b0f9a8b9d338eec0b50ddc62610b23f241f3af8f9a4bf91d2bfdaac294dac1ba34cda03a82e8acebd4e12843a4b9fa7f1924576b4c4681ed2
|
@@ -1,22 +1,9 @@
|
|
1
1
|
module LostInTranslation
|
2
2
|
def string_to_hash(string)
|
3
|
-
array = string.split('
|
3
|
+
array = string.split('---')
|
4
4
|
value = array.pop
|
5
|
-
|
6
|
-
|
7
|
-
puts array.count if array.count > 6
|
8
|
-
(0..anz).each do |key|
|
9
|
-
h[array[0]] = (anz == key ? value : Hash.new) if key == 0
|
10
|
-
h[array[0]][array[1]] = (anz == key ? value : Hash.new) if key == 1
|
11
|
-
h[array[0]][array[1]][array[2]] = (anz == key ? value : Hash.new) if key == 2
|
12
|
-
h[array[0]][array[1]][array[2]][array[3]] = (anz == key ? value : Hash.new) if key == 3
|
13
|
-
h[array[0]][array[1]][array[2]][array[3]][array[4]] = (anz == key ? value : Hash.new) if key == 4
|
14
|
-
h[array[0]][array[1]][array[2]][array[3]][array[4]][array[5]] = (anz == key ? value : Hash.new) if key == 5
|
15
|
-
h[array[0]][array[1]][array[2]][array[3]][array[4]][array[5]][array[6]] = (anz == key ? value : Hash.new) if key == 6
|
16
|
-
h[array[0]][array[1]][array[2]][array[3]][array[4]][array[5]][array[6]][array[7]] = (anz == key ? value : Hash.new) if key == 7
|
17
|
-
### TO BE IMPROVED ! This is shit and I know it.
|
18
|
-
end
|
19
|
-
h
|
5
|
+
arr = array.reverse
|
6
|
+
arr[1..-1].inject({arr[0] => value}){ |memo, i| {i => memo} }
|
20
7
|
end
|
21
8
|
|
22
9
|
def merge_hash(merge_from, merge_to)
|
File without changes
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module LostInTranslation
|
2
|
+
def full_automatic
|
3
|
+
if defined? Rails
|
4
|
+
app_name = Rails.application.class.parent_name
|
5
|
+
lang_2, lang_1 = Translate.ask_for_languages
|
6
|
+
path_1 = "#{Rails.root}/config/locales/#{lang_1}.yml"
|
7
|
+
path_2 = "#{Rails.root}/config/locales/#{lang_2}.yml"
|
8
|
+
else
|
9
|
+
app_name = nil
|
10
|
+
path_2, path_1 = Translate.ask_for_paths
|
11
|
+
|
12
|
+
lang_1 = Translate.get_locale(path_1)
|
13
|
+
lang_2 = Translate.get_locale(path_2)
|
14
|
+
end
|
15
|
+
|
16
|
+
abort('NOPE') unless File.exist?(path_1) && File.exist?(path_2)
|
17
|
+
|
18
|
+
first = YAML.load_file(path_1)
|
19
|
+
second = YAML.load_file(path_2)
|
20
|
+
|
21
|
+
new_strings_array = Translate.clean(first[lang_1], second[lang_2], [lang_2])
|
22
|
+
|
23
|
+
first = {}
|
24
|
+
new_strings_array.each do |string|
|
25
|
+
string = string.split('---').map { |x| x == lang_2 ? x = lang_1 : x }.join('---')
|
26
|
+
result = Translate.string_to_hash(string)
|
27
|
+
Translate.merge_hash(result, first)
|
28
|
+
end
|
29
|
+
|
30
|
+
File.open(path_1, 'w') { |file| file.write(first.to_yaml) }
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module LostInTranslation
|
2
|
+
def half_automatic
|
3
|
+
if defined? Rails
|
4
|
+
app_name = Rails.application.class.parent_name
|
5
|
+
lang_2, lang_1 = Translate.ask_for_languages
|
6
|
+
path_1 = "#{Rails.root}/config/locales/#{lang_1}.yml"
|
7
|
+
path_2 = "#{Rails.root}/config/locales/#{lang_2}.yml"
|
8
|
+
else
|
9
|
+
app_name = nil
|
10
|
+
path_2, path_1 = Translate.ask_for_paths
|
11
|
+
|
12
|
+
lang_1 = Translate.get_locale(path_1)
|
13
|
+
lang_2 = Translate.get_locale(path_2)
|
14
|
+
end
|
15
|
+
|
16
|
+
abort('NOPE') unless File.exist?(path_1) && File.exist?(path_2)
|
17
|
+
|
18
|
+
first = YAML.load_file(path_1)
|
19
|
+
second = YAML.load_file(path_2)
|
20
|
+
|
21
|
+
new_strings_array = Translate.clean(first[lang_1], second[lang_2], [lang_2])
|
22
|
+
|
23
|
+
first = {}
|
24
|
+
new_strings_array.each do |string|
|
25
|
+
string = string.split('---').map { |x| x == lang_2 ? x = lang_1 : x }.join('---')
|
26
|
+
result = Translate.string_to_hash(string)
|
27
|
+
Translate.merge_hash(result, first)
|
28
|
+
end
|
29
|
+
|
30
|
+
File.open(path_1, 'w') { |file| file.write(first.to_yaml) }
|
31
|
+
end
|
32
|
+
end
|
File without changes
|
File without changes
|
data/lib/lost_in_translation.rb
CHANGED
@@ -2,9 +2,11 @@ require "lost_in_translation/version"
|
|
2
2
|
require "lost_in_translation/difference"
|
3
3
|
require "lost_in_translation/hash"
|
4
4
|
require "lost_in_translation/user_interface"
|
5
|
-
require "lost_in_translation/
|
6
|
-
require "lost_in_translation/
|
7
|
-
require "lost_in_translation/
|
5
|
+
require "lost_in_translation/z_recent"
|
6
|
+
require "lost_in_translation/z_interactive"
|
7
|
+
require "lost_in_translation/z_cleanup"
|
8
|
+
require "lost_in_translation/z_half_automatic"
|
9
|
+
require "lost_in_translation/z_full_automatic"
|
8
10
|
require 'lost_in_translation/railtie' if defined?(Rails)
|
9
11
|
|
10
12
|
module LostInTranslation
|
data/lib/tasks/translate.rake
CHANGED
@@ -13,6 +13,7 @@ namespace :translate 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
|
+
Translate.half_automatic
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
@@ -20,18 +21,19 @@ namespace :translate do
|
|
20
21
|
desc "Use Bing-Translator to automatically translate everything"
|
21
22
|
task :full_automatic do
|
22
23
|
return 'to_be_done'
|
24
|
+
Translate.full_automatic
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
26
28
|
namespace :translate do
|
27
|
-
desc "Cleaning out the Yaml-Closet
|
29
|
+
desc "Cleaning out the Yaml-Closet"
|
28
30
|
task :cleanup do
|
29
31
|
Translate.cleanup
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
33
35
|
namespace :translate do
|
34
|
-
desc "Tranlate just your recently changed words"
|
36
|
+
desc "Tranlate just your recently changed words(requires git)"
|
35
37
|
task :recent do
|
36
38
|
abort('Please use this feature inside a Rails-Application') unless defined? Rails
|
37
39
|
Translate.recent
|
data/lost_in_translation.gemspec
CHANGED
@@ -7,10 +7,10 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "lost_in_translation"
|
8
8
|
spec.version = LostInTranslation::VERSION
|
9
9
|
spec.authors = ["Datyv"]
|
10
|
-
spec.email = ["
|
10
|
+
spec.email = ["yvesgoizet@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{A Gem to
|
13
|
-
spec.description = %q{Take two locales and merge them together with different values.}
|
12
|
+
spec.summary = %q{A Gem to compare two locale yamls}
|
13
|
+
spec.description = %q{Take two locales yamls and merge them together with different values.}
|
14
14
|
spec.homepage = "https://github.com/Datyv/lost_in_translation"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
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.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Datyv
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,9 +52,9 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
-
description: Take two locales and merge them together with different values.
|
55
|
+
description: Take two locales yamls and merge them together with different values.
|
56
56
|
email:
|
57
|
-
-
|
57
|
+
- yvesgoizet@gmail.com
|
58
58
|
executables: []
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
@@ -70,14 +70,16 @@ files:
|
|
70
70
|
- bin/console
|
71
71
|
- bin/setup
|
72
72
|
- lib/lost_in_translation.rb
|
73
|
-
- lib/lost_in_translation/cleanup.rb
|
74
73
|
- lib/lost_in_translation/difference.rb
|
75
74
|
- lib/lost_in_translation/hash.rb
|
76
|
-
- lib/lost_in_translation/interactive.rb
|
77
75
|
- lib/lost_in_translation/railtie.rb
|
78
|
-
- lib/lost_in_translation/recent.rb
|
79
76
|
- lib/lost_in_translation/user_interface.rb
|
80
77
|
- lib/lost_in_translation/version.rb
|
78
|
+
- lib/lost_in_translation/z_cleanup.rb
|
79
|
+
- lib/lost_in_translation/z_full_automatic.rb
|
80
|
+
- lib/lost_in_translation/z_half_automatic.rb
|
81
|
+
- lib/lost_in_translation/z_interactive.rb
|
82
|
+
- lib/lost_in_translation/z_recent.rb
|
81
83
|
- lib/tasks/translate.rake
|
82
84
|
- lost_in_translation.gemspec
|
83
85
|
homepage: https://github.com/Datyv/lost_in_translation
|
@@ -100,8 +102,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
102
|
version: '0'
|
101
103
|
requirements: []
|
102
104
|
rubyforge_project:
|
103
|
-
rubygems_version: 2.
|
105
|
+
rubygems_version: 2.6.4
|
104
106
|
signing_key:
|
105
107
|
specification_version: 4
|
106
|
-
summary: A Gem to
|
108
|
+
summary: A Gem to compare two locale yamls
|
107
109
|
test_files: []
|