excel2local 0.1.1 → 0.1.2

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
  SHA256:
3
- metadata.gz: 9ad02ae048f8fd4291bceea7a6b68bb05ab2eb1803b3d616657004ace383c4f6
4
- data.tar.gz: 70a3cba06a8d282f55ea3ebfa0d518cd6c6a55dacdee693baa65dc50c39969a6
3
+ metadata.gz: d697c6f5eac60bf6c0f19108fd084ad19db49d4b1df4b246712473bab052017f
4
+ data.tar.gz: e726b087c7944e6b1004cbc13ad14ea30bedb79f858294b54dd2429b01d7b8b7
5
5
  SHA512:
6
- metadata.gz: 11da4ba91f3e29541eb67089efddfb515079cc0b1c6267492e2da77542bcf6f4ee45d6ad13702f53c46e5ec76435f6d02533356159245aea82ba66421ab80da4
7
- data.tar.gz: 6cc1fc1f8d75b6ea752050b0398f4d4972808ca2596756e1c6c205c61cc98dd45e1bea783a16a4569c2e2c25f435da3207732c734bc96e5d58c1a150af4e93ff
6
+ metadata.gz: 5e891bf1b71920ea6874f3006fc6a82455c7d3f51a131b5de13035943bc67186c890a172abeff8c2619ac374706a21ba5d73586fe92752180406aa56c325016a
7
+ data.tar.gz: b193722d9c3fbdb0bb590feba5a4b1c473beb319082990ee37b24d5f24847fb3aab4f65c1ea39f43c52a70db53e67350596f0f5d748921c4f25c39a52c2fbc6b
data/README.md CHANGED
@@ -1,103 +1,103 @@
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
+ ```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,9 +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 Excel2local::localize! './config/locales/locales.xlsx','./config/locales' to config.ru
8
- Excel2local::localize! './config/locales/locales.xlsx','./config/locales'
9
-
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
data/lib/excel2local.rb CHANGED
@@ -2,6 +2,13 @@ require "excel2local/version"
2
2
  require "roo"
3
3
 
4
4
  module Excel2local
5
+
6
+ def self.localize_all! (locate)
7
+ Dir["#{locate}/*.xlsx"].each { |file|
8
+ localize! "#{file}","#{locate}"
9
+ }
10
+ end
11
+
5
12
  def self.localize! (excel_file, save_place) #excel_file - фаил с переводом
6
13
  puts "Excel2local::localize! from #{excel_file} ---> to #{save_place}/"
7
14
  workbook = Roo::Excelx.new(excel_file) #подсовываем фаил в библиотеку
@@ -10,7 +17,7 @@ module Excel2local
10
17
  workbook.each_with_index {|row, row_index| #начинаем перебор строк
11
18
  if (row_index == 0) then #если первая строка то начинаем создавать файлы локализаций
12
19
  row.each_with_index { |col, col_index| # перебираем колонки
13
- File.open("#{save_place}/#{col}.yml", "w") { |file| file.puts "#{col}:" } if col_index != 0 && col != "#" #если не 1 колонка то создаем фаил локали
20
+ File.open("#{save_place}/#{File.basename(excel_file, ".xlsx")}_#{col}.yml", "w") { |file| file.puts "#{col}:" } if col_index != 0 && col != "#" #если не 1 колонка то создаем фаил локали
14
21
  yml_file[col_index] = col #кладем имя файла в массив в соответствующий индекс
15
22
  simbol_memory[col_index] = []
16
23
  }
@@ -22,13 +29,13 @@ module Excel2local
22
29
  @simbol.to_s.split(".").each_with_index { | simbol, index |
23
30
  simbol = "\'" + simbol + "\'" if [ "true", "false", "on", "off", "yes", "no" ].member?(simbol)
24
31
  if simbol != simbol_memory[col_index][index] then
25
- File.open("#{save_place}/#{yml_file[col_index]}.yml", "a") { |file| file.print " "*(index+1) + "#{simbol}:" } if @simbol.to_s.split(".").length - 1 == index
26
- File.open("#{save_place}/#{yml_file[col_index]}.yml", "a") { |file| file.puts " "*(index+1) + "#{simbol}:" } if @simbol.to_s.split(".").length - 1 != index
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
27
34
  index.upto(@simbol.to_s.split(".").length ) { |n| simbol_memory[col_index].delete_at(n)}
28
35
  end
29
36
  simbol_memory[col_index][index] = simbol
30
37
  }
31
- File.open("#{save_place}/#{yml_file[col_index]}.yml", "a") { |file| file.puts " \'#{col}\'" } # пишем сам символ
38
+ File.open("#{save_place}/#{File.basename(excel_file, ".xlsx")}_#{yml_file[col_index]}.yml", "a") { |file| file.puts " \'#{col}\'" } # пишем сам символ
32
39
  end
33
40
  }
34
41
  end
@@ -1,3 +1,3 @@
1
1
  module Excel2local
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
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.1
4
+ version: 0.1.2
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-14 00:00:00.000000000 Z
11
+ date: 2018-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -76,7 +76,7 @@ files:
76
76
  - example/Your_Rails_App/config/locales/locales.xlsx
77
77
  - example/Your_Rails_App/example.rb
78
78
  - example/locales.xlsx
79
- - excel2local-0.1.0.gem
79
+ - excel2local-0.1.1.gem
80
80
  - excel2local.gemspec
81
81
  - lib/excel2local.rb
82
82
  - lib/excel2local/version.rb
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  version: '0'
101
101
  requirements: []
102
102
  rubyforge_project:
103
- rubygems_version: 2.7.6
103
+ rubygems_version: 2.7.7
104
104
  signing_key:
105
105
  specification_version: 4
106
106
  summary: From excel to locales. Simply and easily!
Binary file