applocale 0.2.8 → 0.2.9

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
- SHA1:
3
- metadata.gz: e84a39280ab284159150cd5263596bdfe45098f9
4
- data.tar.gz: 83bedb2834ff382221e89a20a190f02a9a7d1fb9
2
+ SHA256:
3
+ metadata.gz: f480b988ac9b04365a14cfcc0fb6af05f80dc6ed57074df795115c4e65eccd66
4
+ data.tar.gz: 7ff2ea0fa652e029b3d54f1c97d8c22b8714f0ac15ad888d18b169263f075b7a
5
5
  SHA512:
6
- metadata.gz: 60382d4febffe2a2e84e33d444863b2cea1e3fdf81dddc9f63cccd8f18fc1079061d2eac7e5fec023797b5dbadc96a4b3f9594f297dbec7c4d4078a346d52999
7
- data.tar.gz: b5b170f7e332ec9f0bfbd4d2ea90f7680b583524fe1c0da7ef6ffaa1961782a09eaed81cd27ef889a012d6ca5858be08d3eb8ba67433d8708c7c018af6f39da8
6
+ metadata.gz: 14f9b9bfcd25af8df125c1914d4c658c134f921325c1d1ec5bfc073007f728124c8ea0b5b4454e2abd98be4322c77de43fa0a587976ae694c193c99efef402e8
7
+ data.tar.gz: 1a1214c98a866e60212b0d5a482009703f149abf91cd0221998eddf89655506bd62a8d9dbb5f1f72702067e302d96dcb62aa597ca721f4169cba798433d0dd70
@@ -51,6 +51,7 @@ isSkipEmptyKey: false
51
51
  # return value
52
52
  # end
53
53
 
54
- # def is_skip_by_key(sheetname, lang, key)
54
+ # def is_skip_by_key(sheetname, key)
55
55
  # return true
56
- # end
56
+ # end
57
+
@@ -56,5 +56,3 @@ module Applocale
56
56
  end
57
57
  end
58
58
  end
59
-
60
-
@@ -18,16 +18,19 @@ module Applocale
18
18
  @langlist
19
19
  @sheetobj_list
20
20
  @is_skip_empty_key
21
+ @injectobj
21
22
 
22
- def initialize(platfrom, csv_directory, langlist, sheetobj_list, is_skip_empty_key)
23
- @platform = platfrom
24
- @csv_directory = csv_directory
25
- @langlist = langlist
26
- @sheetobj_list = sheetobj_list
23
+
24
+ def initialize(setting)
25
+ @platform = setting.platform
26
+ @csv_directory = setting.export_to
27
+ @langlist = setting.lang_path_list
28
+ @sheetobj_list = setting.sheet_obj_list
27
29
  @sheetcontent_list = Array.new
28
30
  @allkey_dict = {}
29
31
  @all_error = Array.new
30
- @is_skip_empty_key = is_skip_empty_key
32
+ @is_skip_empty_key = setting.is_skip_empty_key
33
+ @injectobj = setting.injection
31
34
  # puts "Start to Parse CSV: \"#{csv_directory}\" ...".green
32
35
  parse
33
36
  end
@@ -51,8 +54,18 @@ module Applocale
51
54
  rows.each_with_index do |row, index|
52
55
  next if sheet_content.header_rowno == index
53
56
  row_content = parse_row(sheet_name, index, row, sheet_content.keyStr_with_colno, sheet_content.lang_with_colno_list)
54
- handle_duplicate_key_if_any!(row_content)
55
- sheet_content.rowinfo_list.push(row_content)
57
+ next if row_content.nil?
58
+ toskip = false
59
+ if @injectobj.has_is_skip_by_key
60
+ is_skip_by_key = @injectobj.load_is_skip_by_key(sheet_name, row_content.key_str)
61
+ if is_skip_by_key.to_s.downcase == "true"
62
+ toskip = true
63
+ end
64
+ end
65
+ if !toskip
66
+ handle_duplicate_key_if_any!(row_content)
67
+ sheet_content.rowinfo_list.push(row_content)
68
+ end
56
69
  end
57
70
  sheet_content
58
71
  end
@@ -116,6 +129,8 @@ module Applocale
116
129
  if (key_str.nil? || key_str.length == 0)
117
130
  if !@is_skip_empty_key
118
131
  raise "ParseCSVError: Key can not be empty, in sheet #{sheet_name}, row: #{index}, key_str: #{key_str}"
132
+ else
133
+ return
119
134
  end
120
135
  else
121
136
  raise "ParseCSVError: Invaild Key in sheet #{sheet_name}, row: #{index}, key_str: #{key_str}"
@@ -24,17 +24,19 @@ module Applocale
24
24
  @langlist
25
25
  @sheetobj_list
26
26
  @is_skip_empty_key
27
+ @injectobj
27
28
 
28
- def initialize(platfrom, xlsxpath, langlist, sheetobj_list, is_skip_empty_key)
29
- @platform = platfrom
30
- @xlsxpath = xlsxpath
31
- @langlist = langlist
32
- @sheetobj_list = sheetobj_list
29
+ def initialize(setting)
30
+ @platform = setting.platform
31
+ @xlsxpath = setting.xlsxpath
32
+ @langlist = setting.lang_path_list
33
+ @sheetobj_list = setting.sheet_obj_list
33
34
  puts "Start to Parse XLSX: \"#{@xlsxpath}\" ...".green
34
35
  @sheetcontent_list = Array.new
35
36
  @allkey_dict = {}
36
37
  @all_error = Array.new
37
- @is_skip_empty_key = is_skip_empty_key
38
+ @is_skip_empty_key = setting.is_skip_empty_key
39
+ @injectobj = setting.injection
38
40
  self.parse
39
41
  end
40
42
 
@@ -133,6 +135,12 @@ module Applocale
133
135
  end
134
136
 
135
137
  unless keystr.nil?
138
+ if @injectobj.has_is_skip_by_key
139
+ is_skip_by_key = @injectobj.load_is_skip_by_key(sheetname, keystr)
140
+ if is_skip_by_key.to_s.downcase == "true"
141
+ return nil
142
+ end
143
+ end
136
144
  rowinfo = ParseModelModule::RowInfo.new(sheetname, rowno, keystr)
137
145
  lang_with_colno_list.each do |lang_with_colno|
138
146
  cell = cells[lang_with_colno.colno - 1]
@@ -9,9 +9,12 @@ require 'json'
9
9
  module Applocale
10
10
  class ConvertToStrFile
11
11
 
12
- def self.convert(platform, lang_path_list, sheetcontent_list, rubycode)
13
12
 
14
- injectObj = Applocale::Injection.load(rubycode)
13
+ def self.convert(setting, sheetcontent_list)
14
+
15
+ platform = setting.platform
16
+ lang_path_list = setting.lang_path_list
17
+ injectObj = setting.injection
15
18
 
16
19
  lang_path_list.each do |langpath_obj|
17
20
  puts "Start to convert to string file for [\"#{langpath_obj.lang}\"] #{langpath_obj.filepath}...".green
@@ -73,12 +76,6 @@ module Applocale
73
76
  target.puts('')
74
77
  contentlist.each do |rowinfo|
75
78
  content = rowinfo.content_dict[langpath_obj.lang]
76
- if injectObj.has_is_skip_by_key
77
- is_skip_by_key = injectObj.load_is_skip_by_key(sheetcontent.sheetname, langpath_obj.lang, rowinfo.key_str)
78
- if is_skip_by_key.to_s.downcase == "true"
79
- next
80
- end
81
- end
82
79
  value = self.add_escape(platform, langpath_obj.lang, rowinfo.key_str, content, injectObj)
83
80
  target.puts("\"#{rowinfo.key_str}\" = \"#{value}\";")
84
81
  end
@@ -95,12 +92,6 @@ module Applocale
95
92
  contentlist = sheetcontent.get_rowInfo_sortby_key
96
93
  contentlist.each do |rowinfo|
97
94
  content = rowinfo.content_dict[langpath_obj.lang]
98
- if injectObj.has_is_skip_by_key
99
- is_skip_by_key = injectObj.load_is_skip_by_key(sheetcontent.sheetname, langpath_obj.lang, rowinfo.key_str)
100
- if is_skip_by_key.to_s.downcase == "true"
101
- next
102
- end
103
- end
104
95
  value = self.add_escape(platform, langpath_obj.lang, rowinfo.key_str, content, injectObj)
105
96
  target.puts(" <string name=\"#{rowinfo.key_str}\">#{value}</string>")
106
97
  end
@@ -118,16 +109,6 @@ module Applocale
118
109
  value = add_escape(platform, lang_path_obj.lang, row.key_str, content, inject_obj)
119
110
  [row.key_str, value]
120
111
  end.to_h
121
- newResult = newResult.select do |key, value|
122
- to_skip = false
123
- if inject_obj.has_is_skip_by_key
124
- is_skip_by_key = inject_obj.load_is_skip_by_key(sheet_content.sheetname, lang_path_obj.lang, key)
125
- if is_skip_by_key.to_s.downcase == "true"
126
- to_skip = true
127
- end
128
- end
129
- !to_skip
130
- end
131
112
  newResult
132
113
  end.reduce({}, :merge)
133
114
  section_last_row = sheet_content_list
@@ -68,11 +68,11 @@ module Applocale
68
68
  end
69
69
  case setting.export_format
70
70
  when 'csv'
71
- parser = Applocale::ParseCSV.new(setting.platform, setting.export_to, setting.lang_path_list, setting.sheet_obj_list, setting.is_skip_empty_key)
71
+ parser = Applocale::ParseCSV.new(setting)
72
72
  when 'xlsx'
73
- parser = Applocale::ParseXLSX.new(setting.platform, setting.xlsxpath, setting.lang_path_list, setting.sheet_obj_list, setting.is_skip_empty_key)
73
+ parser = Applocale::ParseXLSX.new(setting)
74
74
  end
75
- ConvertToStrFile.convert(setting.platform, setting.lang_path_list,parser.result, setting.rubycode)
75
+ ConvertToStrFile.convert(setting, parser.result)
76
76
  end
77
77
 
78
78
  def self.start_reverse( is_skip, projpath = Dir.pwd)
@@ -21,7 +21,7 @@ require 'colorize'
21
21
  module Applocale
22
22
  module Config
23
23
  class Setting
24
- attr_accessor :configfile_pathstr, :link, :platform, :xlsxpath, :google_credentials_path, :lang_path_list, :sheet_obj_list, :rubycode, :export_format, :export_to, :is_skip_empty_key
24
+ attr_accessor :configfile_pathstr, :link, :platform, :xlsxpath, :google_credentials_path, :lang_path_list, :sheet_obj_list, :rubycode, :export_format, :export_to, :is_skip_empty_key, :injection
25
25
  def initialize(configfile_pathstr)
26
26
  self.configfile_pathstr = configfile_pathstr
27
27
  self.lang_path_list = Array.new
@@ -3,6 +3,7 @@ require File.expand_path('../file_util.rb', __FILE__)
3
3
  require File.expand_path('../error_util.rb', __FILE__)
4
4
  require File.expand_path('../platform.rb', __FILE__)
5
5
  require File.expand_path('../../Core/setting.rb', __FILE__)
6
+ require File.expand_path('../injection.rb', __FILE__)
6
7
 
7
8
  require 'pathname'
8
9
 
@@ -86,6 +87,8 @@ module Applocale
86
87
  isSkipEmptyKey = config_yaml['isSkipEmptyKey']
87
88
  setting = Applocale::Config::Setting.new(self.configfile_pathstr)
88
89
  setting.rubycode = rubycode
90
+ setting.injection = Applocale::Injection.load(rubycode)
91
+
89
92
  unless link.nil? || link.length == 0
90
93
  if (link =~ /^https/).nil? && (link =~ /^http/).nil?
91
94
  error = ErrorUtil::ConfigFileInValid.new("Invalid link for [link] : #{link}")
@@ -81,8 +81,9 @@ module Applocale
81
81
  end
82
82
 
83
83
  public
84
- def load_is_skip_by_key(sheetname, lang, key)
85
- return is_skip_by_key(sheetname, lang, key)
84
+ def load_is_skip_by_key(sheetname, key)
85
+ return is_skip_by_key(sheetname, key)
86
86
  end
87
+
87
88
  end
88
89
  end
@@ -1,3 +1,3 @@
1
1
  module Applocale
2
- VERSION = "0.2.8"
2
+ VERSION = "0.2.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: applocale
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kennix
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-29 00:00:00.000000000 Z
11
+ date: 2019-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -114,9 +114,10 @@ dependencies:
114
114
  - - ">="
115
115
  - !ruby/object:Gem::Version
116
116
  version: 3.3.23
117
- description: It can convert file between string and xlsx, also support download xlsx
118
- or csv from google. You can also setup conversion logic for string value of each
119
- project. Support ios and android.
117
+ description: Applocale is a localization tool, It can convert file between string
118
+ and xlsx ,csv, also support download xlsx or csv from google. You can also setup
119
+ conversion logic for string value of each project. Support ios, android and json
120
+ format.
120
121
  email:
121
122
  - kennixdev@gmail.com
122
123
  - johnwongapi@gmail.com
@@ -173,9 +174,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
174
  version: '0'
174
175
  requirements: []
175
176
  rubyforge_project:
176
- rubygems_version: 2.6.6
177
+ rubygems_version: 2.7.7
177
178
  signing_key:
178
179
  specification_version: 4
179
- summary: for mobile application to manage locale
180
+ summary: for mobile application to manage localization
180
181
  test_files: []
181
- has_rdoc: