excel2local 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d697c6f5eac60bf6c0f19108fd084ad19db49d4b1df4b246712473bab052017f
4
- data.tar.gz: e726b087c7944e6b1004cbc13ad14ea30bedb79f858294b54dd2429b01d7b8b7
3
+ metadata.gz: bbe5ef4d13e102175023bfc553066627b68860c61fe27c70efcea83c73007243
4
+ data.tar.gz: 98c3ed0a27538be8129c664adbb17836eed0585cab36e9a39986ff9b8f0bc494
5
5
  SHA512:
6
- metadata.gz: 5e891bf1b71920ea6874f3006fc6a82455c7d3f51a131b5de13035943bc67186c890a172abeff8c2619ac374706a21ba5d73586fe92752180406aa56c325016a
7
- data.tar.gz: b193722d9c3fbdb0bb590feba5a4b1c473beb319082990ee37b24d5f24847fb3aab4f65c1ea39f43c52a70db53e67350596f0f5d748921c4f25c39a52c2fbc6b
6
+ metadata.gz: e2f8fcd5099e65ac9be893756e1ace9dd9451f3dd53679d6b15381be1ebf0795e5a210960b95359ebfa2e803a4f63a109945e0c6b48307c9c4a5d779196c40bf
7
+ data.tar.gz: 2af551413539260f0668055f8645e3ed8adf1b0486e079e9fe64de08fa2334b2e75015739af6af923dd6f186b5b04772cbc583eb5b6687ebf20897d240e0e5ce
data/README.md CHANGED
@@ -1,103 +1,117 @@
1
- # Excel2local
2
- Hey! You want to EASY manage your localise?
3
- Correct and change the location in Excel. Send it for transfer to outsourcing. Save time, spend it on yourself.
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
- ```ruby
9
- gem 'excel2local'
10
- ```
11
-
12
- And then execute:
13
-
14
- $ bundle
15
-
16
- Or install it yourself as:
17
-
18
- $ gem install excel2local
19
-
20
- ## Usage if rails
21
- Correct file localises.xlsx and place it to yiur your_rails_app/config/locales/
22
- and type command in config.ru (for make localises file befoure every start rails) or there where you want to make locales
23
- ```ruby
24
- Excel2local::localize! './config/locales/locales.xlsx','./config/locales'
25
- ```
26
- notice: old locales files will be deleted
27
-
28
- ## Usage if not rails
29
- require gem if not rails
30
- ```ruby
31
- require 'excel2local'
32
-
33
- Excel2local::localize! '****.xlsx','locales path'
34
- ```
35
-
36
- ## Correct localises.xlsx or other *.xlsx
37
- Such Excel configuration = 3 files of locales: en.yml, ru.yml,ru_fan.yml
38
-
39
- --- | en | ru | ru_fun |
40
- --- | --- | --- | --- |
41
- hello | hello | привет | приувет |
42
- hello.world | hello world | привет мир | YO! |
43
- head.info.true | true | правда | тру |
44
- head.info.connect | connect to server | соединение | контакт |
45
- head.true.test | test | тест | эй бро |
46
-
47
-
48
- en.yml
49
- ```ruby
50
- en:
51
- hello: 'hello'
52
- world: 'hello world'
53
- head:
54
- info:
55
- 'true': 'true'
56
- connect: 'connect to server'
57
- 'true':
58
- test: 'test'
59
- ```
60
- ru.yml
61
- ```ruby
62
- ru:
63
- hello: 'привет'
64
- world: 'привет мир'
65
- head:
66
- info:
67
- 'true': 'правда'
68
- connect: 'соединение'
69
- 'true':
70
- test: 'тест'
71
- ```
72
- ru_fun
73
- ```ruby
74
- ru_fun:
75
- hello: 'приувет'
76
- world: 'YO!'
77
- head:
78
- info:
79
- 'true': 'тру'
80
- connect: 'контакт '
81
- 'true':
82
- test: 'эй бро'
83
- ```
84
-
85
- You see, that the specific is correctly processed (true = 'true')
86
- and for example
87
- x1.y1.n1 =
88
- ```ruby
89
- x1:
90
- y1:
91
- n1:
92
- ```
93
- ## Development
94
- gem uses beautiful gem - "roo" --> https://github.com/roo-rb/roo
95
-
96
-
97
- ## Contributing
98
-
99
- Bug reports and pull requests are welcome on GitHub at https://github.com/eliseevTech/excel2local or eliseevmail@ya.ru
100
-
101
- ## License
102
-
103
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
1
+ # Excel2local
2
+ Hey! You want to EASY manage your localise?
3
+ Correct and change the location in Excel. Send it for transfer to outsourcing. Save time, spend it on yourself.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+ ```ruby
9
+ gem 'excel2local'
10
+ ```
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install excel2local
19
+
20
+ ## Usage if rails
21
+ Correct file localises.xlsx and place it to yiur your_rails_app/config/locales/
22
+ and type command in config.ru (for make localises file befoure every start rails) or there where you want to make locales
23
+
24
+ for one excel file
25
+ ```ruby
26
+ Excel2local::localize! './config/locales/locales.xlsx','./config/locales'
27
+ ```
28
+ or for all files in folder
29
+ ```ruby
30
+ Excel2local::localize_all! './config/locales'
31
+ ```
32
+
33
+ notice: old locales files will be deleted!!!
34
+
35
+ ## Usage if not rails
36
+ require gem if not rails
37
+ ```ruby
38
+ require 'excel2local'
39
+ ```
40
+ for one file
41
+ ```ruby
42
+ Excel2local::localize! '****.xlsx','locales path'
43
+ ```
44
+ for all files
45
+ ```ruby
46
+ Excel2local::localize_all! 'locales path'
47
+ ```
48
+
49
+
50
+ ## Correct localises.xlsx or other *.xlsx
51
+ Such Excel configuration = 3 files of locales: en.yml, ru.yml,ru_fan.yml
52
+
53
+ --- | en | ru | ru_fun |
54
+ --- | --- | --- | --- |
55
+ hello | hello | привет | приувет |
56
+ hello.world | hello world | привет мир | YO! |
57
+ head.info.true | true | правда | тру |
58
+ head.info.connect | connect to server | соединение | контакт |
59
+ head.true.test | test | тест | эй бро |
60
+
61
+
62
+ #{filename}_en.yml
63
+ ```ruby
64
+ en:
65
+ hello: 'hello'
66
+ world: 'hello world'
67
+ head:
68
+ info:
69
+ 'true': 'true'
70
+ connect: 'connect to server'
71
+ 'true':
72
+ test: 'test'
73
+ ```
74
+ #{filename}_ru.yml
75
+ ```ruby
76
+ ru:
77
+ hello: 'привет'
78
+ world: 'привет мир'
79
+ head:
80
+ info:
81
+ 'true': 'правда'
82
+ connect: 'соединение'
83
+ 'true':
84
+ test: 'тест'
85
+ ```
86
+ #{filename}_ru_fun
87
+ ```ruby
88
+ ru_fun:
89
+ hello: 'приувет'
90
+ world: 'YO!'
91
+ head:
92
+ info:
93
+ 'true': 'тру'
94
+ connect: 'контакт '
95
+ 'true':
96
+ test: 'эй бро'
97
+ ```
98
+
99
+ You see, that the specific is correctly processed (true = 'true')
100
+ and for example
101
+ x1.y1.n1 =
102
+ ```ruby
103
+ x1:
104
+ y1:
105
+ n1:
106
+ ```
107
+ ## Development
108
+ gem uses beautiful gem - "roo" --> https://github.com/roo-rb/roo
109
+
110
+
111
+ ## Contributing
112
+
113
+ Bug reports and pull requests are welcome on GitHub at https://github.com/eliseevTech/excel2local or eliseevmail@ya.ru
114
+
115
+ ## License
116
+
117
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -1,11 +1,11 @@
1
- #add locales.xlsx to Your_Rails_App/config/locales/
2
-
3
- # add gem to the gemfile
4
- # gem "excel2local", '~> 0.1.3' to
5
- require "Excel2local"
6
-
7
- # add next for localize only one file './config/locales/locales.xlsx' to './config/locales'
8
- #Excel2local::localize! './config/locales/locales.xlsx','./config/locales'
9
-
10
- #add next to config.ru for localize all files from './config/locales'
11
- Excel2local::localize_all! './config/locales'
1
+ #add locales.xlsx to Your_Rails_App/config/locales/
2
+
3
+ # add gem to the gemfile
4
+ # gem "excel2local", '~> 0.1.3' to
5
+ require "excel2local"
6
+
7
+ # add next for localize only one file './config/locales/locales.xlsx' to './config/locales'
8
+ #Excel2local::localize! './config/locales/locales.xlsx','./config/locales'
9
+
10
+ #add next to config.ru for localize all files from './config/locales'
11
+ Excel2local::localize_all! './config/locales'
Binary file
@@ -1,44 +1,54 @@
1
- require "excel2local/version"
2
- require "roo"
3
-
4
- module Excel2local
5
-
6
- def self.localize_all! (locate)
7
- Dir["#{locate}/*.xlsx"].each { |file|
8
- localize! "#{file}","#{locate}"
9
- }
10
- end
11
-
12
- def self.localize! (excel_file, save_place) #excel_file - фаил с переводом
13
- puts "Excel2local::localize! from #{excel_file} ---> to #{save_place}/"
14
- workbook = Roo::Excelx.new(excel_file) #подсовываем фаил в библиотеку
15
- yml_file = [] # создаем массив для имен файлов
16
- simbol_memory = []
17
- workbook.each_with_index {|row, row_index| #начинаем перебор строк
18
- if (row_index == 0) then #если первая строка то начинаем создавать файлы локализаций
19
- row.each_with_index { |col, col_index| # перебираем колонки
20
- File.open("#{save_place}/#{File.basename(excel_file, ".xlsx")}_#{col}.yml", "w") { |file| file.puts "#{col}:" } if col_index != 0 && col != "#" #если не 1 колонка то создаем фаил локали
21
- yml_file[col_index] = col #кладем имя файла в массив в соответствующий индекс
22
- simbol_memory[col_index] = []
23
- }
24
- else
25
- row.each_with_index { |col, col_index| #если не первая строка
26
- @simbol = col if col_index == 0 #если
27
- #break if #
28
- if (col_index != 0) and (@simbol != nil ) and (col != nil)
29
- @simbol.to_s.split(".").each_with_index { | simbol, index |
30
- simbol = "\'" + simbol + "\'" if [ "true", "false", "on", "off", "yes", "no" ].member?(simbol)
31
- if simbol != simbol_memory[col_index][index] then
32
- File.open("#{save_place}/#{File.basename(excel_file, ".xlsx")}_#{yml_file[col_index]}.yml", "a") { |file| file.print " "*(index+1) + "#{simbol}:" } if @simbol.to_s.split(".").length - 1 == index
33
- File.open("#{save_place}/#{File.basename(excel_file, ".xlsx")}_#{yml_file[col_index]}.yml", "a") { |file| file.puts " "*(index+1) + "#{simbol}:" } if @simbol.to_s.split(".").length - 1 != index
34
- index.upto(@simbol.to_s.split(".").length ) { |n| simbol_memory[col_index].delete_at(n)}
35
- end
36
- simbol_memory[col_index][index] = simbol
37
- }
38
- File.open("#{save_place}/#{File.basename(excel_file, ".xlsx")}_#{yml_file[col_index]}.yml", "a") { |file| file.puts " \'#{col}\'" } # пишем сам символ
39
- end
40
- }
41
- end
42
- }
43
- end
1
+ require "excel2local/version"
2
+ require "roo"
3
+
4
+ module Excel2local
5
+
6
+ def self.localize_all! (locate)
7
+ Dir["#{locate}/*.xlsx"].each { |file|
8
+ localize! "#{file}","#{locate}"
9
+ }
10
+ end
11
+
12
+ def self.localize! (excel_file, save_place) #excel_file - фаил с переводом
13
+ puts "Excel2local::localize! from #{excel_file} ---> to #{save_place}/"
14
+ workbook = Roo::Excelx.new(excel_file) #подсовываем фаил в библиотеку
15
+ yml_file = [] # создаем массив для имен файлов
16
+ simbol_memory = []
17
+ workbook.each_with_index {|row, row_index| #начинаем перебор строк
18
+ if (row_index == 0) then #если первая строка то начинаем создавать файлы локализаций
19
+ row.each_with_index { |col, col_index| # перебираем колонки
20
+ File.open("#{save_place}/#{File.basename(excel_file, ".xlsx")}_#{col}.yml", "w") { |file| file.puts "#{col}:" } if col_index != 0 && col != "#" #если не 1 колонка то создаем фаил локали
21
+ yml_file[col_index] = col #кладем имя файла в массив в соответствующий индекс
22
+ simbol_memory[col_index] = []
23
+ }
24
+ else
25
+ row.each_with_index { |col, col_index| #если не первая строка
26
+ @simbol = col if col_index == 0 #если
27
+ #break if #
28
+ if (col_index != 0) and (@simbol != nil ) and (col != nil)
29
+ @simbol.to_s.split(".").each_with_index { | simbol, index |
30
+ simbol = "\'" + simbol + "\'" if [ "true", "false", "on", "off", "yes", "no" ].member?(simbol)
31
+ if simbol != simbol_memory[col_index][index] then
32
+ File.open("#{save_place}/#{File.basename(excel_file, ".xlsx")}_#{yml_file[col_index]}.yml", "a") { |file| file.print " "*(index+1) + "#{simbol}:" } if @simbol.to_s.split(".").length - 1 == index
33
+ File.open("#{save_place}/#{File.basename(excel_file, ".xlsx")}_#{yml_file[col_index]}.yml", "a") { |file| file.puts " "*(index+1) + "#{simbol}:" } if @simbol.to_s.split(".").length - 1 != index
34
+ index.upto(@simbol.to_s.split(".").length ) { |n| simbol_memory[col_index].delete_at(n)}
35
+ end
36
+ simbol_memory[col_index][index] = simbol
37
+ }
38
+ File.open("#{save_place}/#{File.basename(excel_file, ".xlsx")}_#{yml_file[col_index]}.yml", "a") { |file| file.puts " \'#{col}\'" } # пишем сам символ
39
+ end
40
+ }
41
+ end
42
+ }
43
+ end
44
+
45
+ def self.backup_all! (locate)
46
+ print "Excel2local::backup_all! to #{locate}/backups .. "
47
+ Dir.mkdir("#{locate}/backups") if File.directory?("#{locate}/backups") == false
48
+ Dir.mkdir(dir_name = "#{locate}/backups/#{Time.now.to_i}")
49
+ Dir["#{locate}/*.yml"].each { |file|
50
+ FileUtils.cp(file, dir_name)
51
+ }
52
+ puts "Done!"
53
+ end
44
54
  end
@@ -1,3 +1,3 @@
1
- module Excel2local
2
- VERSION = "0.1.2"
3
- end
1
+ module Excel2local
2
+ VERSION = "0.1.3"
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: excel2local
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eliseev_EV
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-23 00:00:00.000000000 Z
11
+ date: 2018-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -73,10 +73,14 @@ files:
73
73
  - Rakefile
74
74
  - bin/console
75
75
  - bin/setup
76
+ - example/Your_Rails_App/.DS_Store
77
+ - example/Your_Rails_App/config/.DS_Store
78
+ - example/Your_Rails_App/config/locales/.DS_Store
76
79
  - example/Your_Rails_App/config/locales/locales.xlsx
77
80
  - example/Your_Rails_App/example.rb
78
81
  - example/locales.xlsx
79
82
  - excel2local-0.1.1.gem
83
+ - excel2local-0.1.2.gem
80
84
  - excel2local.gemspec
81
85
  - lib/excel2local.rb
82
86
  - lib/excel2local/version.rb
@@ -100,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
104
  version: '0'
101
105
  requirements: []
102
106
  rubyforge_project:
103
- rubygems_version: 2.7.7
107
+ rubygems_version: 2.7.6
104
108
  signing_key:
105
109
  specification_version: 4
106
110
  summary: From excel to locales. Simply and easily!