lost_in_translation 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a3bad89e7e9d374aea300f0e82e7dd12150a88c1
4
- data.tar.gz: b398954b97e65e4d97c281f8c9c1b63a2c41ab02
3
+ metadata.gz: 376e0e16d5dac4cf5bd57a2fefab9678679d4b31
4
+ data.tar.gz: 21501c8cae154a3d35cf11e82ed4fc0011264e36
5
5
  SHA512:
6
- metadata.gz: f7ea20ba1c81836f792c9cf62e40141fd633e5e3346b2302393eb7f9c95e765fc38f254ffec11a425481f9e45432414bc34fbff612b64c760f3e2eb473d8a0de
7
- data.tar.gz: f53813c261b74a4b0f9a8b9d338eec0b50ddc62610b23f241f3af8f9a4bf91d2bfdaac294dac1ba34cda03a82e8acebd4e12843a4b9fa7f1924576b4c4681ed2
6
+ metadata.gz: ed95ba8c0b043f45ff0d50e6394265fcee1d94c6c340316ac8bcd541e31c9703c24af0543dc7991f51c28a8c777c0dae0753348fd1d231dbc45a8752b595873b
7
+ data.tar.gz: 78176e768c60045d507b7af3675dda61646bee4143cce545778467c29e109d225de644da3d7b46a66b9703b639e4a21c6b75d9674fc8329418cba97b10864242
data/README.md CHANGED
@@ -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 translate:interactive
39
+ rake t9n: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 translate:recent
47
+ rake t9n:recent
48
48
  ```
49
49
  REQUIRED: Connection to Git
50
50
  This script will ask you for the missing value.
@@ -53,7 +53,7 @@ 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 translate:cleanup
56
+ rake t9n: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!!!!
@@ -1,13 +1,14 @@
1
- require "lost_in_translation/version"
2
1
  require "lost_in_translation/difference"
2
+ require "lost_in_translation/file_functions"
3
3
  require "lost_in_translation/hash"
4
+ require 'lost_in_translation/railtie' if defined?(Rails)
4
5
  require "lost_in_translation/user_interface"
6
+ require "lost_in_translation/version"
5
7
  require "lost_in_translation/z_recent"
6
8
  require "lost_in_translation/z_interactive"
7
9
  require "lost_in_translation/z_cleanup"
8
10
  require "lost_in_translation/z_half_automatic"
9
11
  require "lost_in_translation/z_full_automatic"
10
- require 'lost_in_translation/railtie' if defined?(Rails)
11
12
 
12
13
  module LostInTranslation
13
14
 
@@ -0,0 +1,47 @@
1
+ module LostInTranslation
2
+ def prepare_paths(path_1, path_2, post)
3
+ [path_1, path_2].each do |p|
4
+ prepare_yaml(p, post)
5
+ end
6
+ end
7
+
8
+ def prepare_yaml(path, post)
9
+ text = File.read(path)
10
+ snippets = define_snippets
11
+
12
+ snippets = snippets.reverse if post
13
+ snippets.each do |snippet|
14
+ snippet = snippet.reverse if post
15
+ text = text.gsub(snippet.first, snippet.second)
16
+ end
17
+
18
+ if post
19
+ variables = text.scan(/varyberryterry.*/)
20
+ variables.each do |var|
21
+ new_var = var.gsub(':', '')
22
+ new_var = new_var.gsub('varyberryterry', ': &')
23
+ text = text.gsub(var, new_var)
24
+ end
25
+ else
26
+ variables = text.scan(/: &.*/)
27
+ variables.each do |var|
28
+ new_var = var.gsub(': &', 'varyberryterry')
29
+ new_var += ':'
30
+ text = text.gsub(var, new_var)
31
+ end
32
+ end
33
+
34
+ File.open(path, "w") {|file| file.puts text }
35
+ end
36
+
37
+ def define_snippets
38
+ snippets = []
39
+ snippets << ["<<", "a_greater_than_sign"]
40
+ snippets << ["*", "an_asterik_sign"]
41
+ snippets << ["!", "a_bang_sign"]
42
+ snippets << ["%", "a_percentage_sign"]
43
+ snippets << ['a_bang_sign \'', '\'a_bang_sign']
44
+ # snippets << ["&", "this_and_snippet_variable"]
45
+ snippets
46
+ end
47
+ end
@@ -1,3 +1,3 @@
1
1
  module LostInTranslation
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -15,6 +15,8 @@ module LostInTranslation
15
15
 
16
16
  abort('NOPE') unless File.exist?(path_1) && File.exist?(path_2)
17
17
 
18
+ prepare_yamls(path_1, path_2, false)
19
+
18
20
  first = YAML.load_file(path_1)
19
21
  second = YAML.load_file(path_2)
20
22
 
@@ -28,5 +30,7 @@ module LostInTranslation
28
30
  end
29
31
 
30
32
  File.open(path_1, 'w') { |file| file.write(first.to_yaml) }
33
+
34
+ prepare_yamls(path_1, path_2, false)
31
35
  end
32
36
  end
@@ -16,6 +16,9 @@ module LostInTranslation
16
16
  abort('NOPE') unless File.exist?(path_1) && File.exist?(path_2)
17
17
  abort('Well, in that case, forget it!') unless Translate.ask_for_permission(lang_1,lang_2,app_name)
18
18
 
19
+ prepare_paths(path_1, path_2, true)
20
+ prepare_paths(path_1, path_2, false)
21
+
19
22
  first = YAML.load_file(path_1)
20
23
  second = YAML.load_file(path_2)
21
24
 
@@ -28,10 +31,12 @@ module LostInTranslation
28
31
 
29
32
  if Translate.ask_for_sorting(lang_1, app_name)
30
33
  first = Translate.sort_hash(first)
31
- File.open(path_1, 'w') { |file| file.write(first.to_yaml) }
34
+ File.open(path_1, 'w') { |file| file.write(first.to_yaml(line_width: -1)) }
32
35
  end
33
-
36
+
34
37
  second = Translate.sort_hash(second) if Translate.ask_for_sorting(lang_2, app_name)
35
- File.open(path_2, 'w') { |file| file.write(second.to_yaml) }
38
+ File.open(path_2, 'w') { |file| file.write(second.to_yaml(line_width: -1)) }
39
+
40
+ prepare_paths(path_1, path_2, true)
36
41
  end
37
42
  end
@@ -11,6 +11,8 @@ module LostInTranslation
11
11
  FileUtils.cp(path_1, copy_path_1)
12
12
  `git checkout "#{path_1}"`
13
13
 
14
+ prepare_yamls(path_1, copy_path_1, false)
15
+
14
16
  first = YAML.load_file(path_1)
15
17
  first_copy = YAML.load_file(copy_path_1)
16
18
  second = YAML.load_file(path_2)
@@ -29,6 +31,7 @@ module LostInTranslation
29
31
 
30
32
  second = Translate.sort_hash(second) if Translate.ask_for_sorting(lang_2, app_name)
31
33
  File.open(path_2, 'w') { |file| file.write(second.to_yaml) }
34
+ prepare_yamls(path_1, copy_path_1, true)
32
35
 
33
36
  FileUtils.rm(copy_path_1)
34
37
  end
@@ -2,14 +2,14 @@ require 'yaml'
2
2
  require 'lost_in_translation'
3
3
  require 'fileutils'
4
4
 
5
- namespace :translate do
5
+ namespace :t9n do
6
6
  desc "Make the locale-yamls equal again(Interactive)"
7
7
  task :interactive do
8
8
  Translate.interactive
9
9
  end
10
10
  end
11
11
 
12
- namespace :translate do
12
+ namespace :t9n do
13
13
  desc "Use Bing-Translator as a suggestion for translation"
14
14
  task :half_automatic do
15
15
  return 'to_be_done'
@@ -17,7 +17,7 @@ namespace :translate do
17
17
  end
18
18
  end
19
19
 
20
- namespace :translate do
20
+ namespace :t9n do
21
21
  desc "Use Bing-Translator to automatically translate everything"
22
22
  task :full_automatic do
23
23
  return 'to_be_done'
@@ -25,15 +25,15 @@ namespace :translate do
25
25
  end
26
26
  end
27
27
 
28
- namespace :translate do
28
+ namespace :t9n do
29
29
  desc "Cleaning out the Yaml-Closet"
30
30
  task :cleanup do
31
31
  Translate.cleanup
32
32
  end
33
33
  end
34
34
 
35
- namespace :translate do
36
- desc "Tranlate just your recently changed words(requires git)"
35
+ namespace :t9n do
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
  Translate.recent
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.1.0
4
+ version: 0.2.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-07-02 00:00:00.000000000 Z
11
+ date: 2017-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -71,6 +71,7 @@ files:
71
71
  - bin/setup
72
72
  - lib/lost_in_translation.rb
73
73
  - lib/lost_in_translation/difference.rb
74
+ - lib/lost_in_translation/file_functions.rb
74
75
  - lib/lost_in_translation/hash.rb
75
76
  - lib/lost_in_translation/railtie.rb
76
77
  - lib/lost_in_translation/user_interface.rb
@@ -102,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
103
  version: '0'
103
104
  requirements: []
104
105
  rubyforge_project:
105
- rubygems_version: 2.6.4
106
+ rubygems_version: 2.5.1
106
107
  signing_key:
107
108
  specification_version: 4
108
109
  summary: A Gem to compare two locale yamls